Movatterモバイル変換
[0]ホーム
[Python-Dev] Object customization (was: Arbitrary attributes on funcs and methods)
Vladimir MarangozovVladimir.Marangozov@inrialpes.fr
Thu, 13 Apr 2000 20:10:33 +0200 (CEST)
Gordon McMillan wrote:>> I don't see anything here but an argument that allowing> attributes on function objects makes them vaguely similar to> instance objects. To the extent that I can agree with that, I fail> to see any harm in it.>To the extent it encourages confusion, I think it sucks.>>> def this():... sucks = "no"...>>> this.sucks = "yes">>>>>> print this.sucks'yes'Why on earth 'sucks' is not the object defined in the function's namespace?Who made that deliberate decision? Clearly 'this' defines a new namespace,so it'll be also legitimate to get a NameError, or to:>>> print this.sucks'no'Don't you think?And don't explain to me that this is because there's a code object,different from the function object, which is compiled at the function'sdefinition, then assotiated with the function object, blah, blah, blah...-- Vladimir MARANGOZOV |Vladimir.Marangozov@inrialpes.frhttp://sirac.inrialpes.fr/~marangoz | tel:(+33-4)76615277 fax:76615252
[8]ページ先頭