Movatterモバイル変換
[0]ホーム
[Python-Dev] Arbitrary attributes on funcs and methods
M.-A. Lemburgmal@lemburg.com
Wed, 12 Apr 2000 19:55:19 +0200
Jeremy Hylton wrote:> BAW> Think about my proposal this way: it actually removes a> BAW> restriction.>> I think this is really the crux of the matter! The proposal removes> a useful restriction.Not sure... I wouldn't mind having the ability to add attributesto all Python objects at my own liking. Ok, maybe a bit farfetched, but the idea would certainly be useful in some cases,e.g. to add new methods to built-in types or to add encodingname information to strings... > The alternatives /F suggested seem clearer to me that sticking new> attributes on functions and methods. Three things I like about the> approach: It affords an opportunity to be very clear about how the> attributes are intended to be used. I suspect it would be easier to> describe with a static type system. It prevents confusion and errors> that might result from unprincipled use of function attributes.The nice side-effect of having these function/method instancedictionaries is that they follow class inheritance. Somethingwhich is hard to do right with Fredrik's approach.I suspect that in Py3K we'll only have one type of classsystem: everything inherits from one global base class -- seenin that light, method attributes are really nothing unusual,since all instances would have instance dictionaries anyway(well maybe only on demand, but that's another story).Anyway, more power to you Barry :-)-- Marc-Andre Lemburg______________________________________________________________________Business:http://www.lemburg.com/Python Pages:http://www.lemburg.com/python/
[8]ページ先頭