Metaclass' __init__ Does not Initialize

Alex Martelli aleax at aleax.it
Wed Nov 12 11:14:55 CET 2003


achan wrote:

> As I was trying to create a metaclass, I found out that __init__ defined
> in it does not initializes at all:
   ...
>         def __init__(self):
>             for k in self.__slots__:
>                 k = 'something'

Haven't looked at the rest of your code, but this part can't possibly
be right -- you're just rebinding local variable k over and over,
uselessly.  Perhaps you want the loop's body to be
    setattr(self, k, 'something')
...?


Alex





More information about the Python-list mailing list