__init__ & attributes clarification

Bengt Richter bokr at oz.net
Mon Feb 3 03:41:45 EST 2003


On Mon, 03 Feb 2003 07:40:50 GMT, Alex Martelli <aleax at aleax.it> wrote:
[...]
>
>class Subtler:
>    xx = 23
>    def setinself(self): setattr(self, 'xx', 45)
>    def setinclass(self): setattr(Subtler, 'xx', 67)
>
[...]

Typographically, I like the above way of spelling Subtler,
but I don't like the dependency on the global binding
of the Subtler name, so I've taken to using self.__class__
instead in contexts like that. Do you have any strong
feelings one way or the other?

Regards,
Bengt Richter




More information about the Python-list mailing list