Question on metaclasses
Reinhold Birkenfeld
reinhold-birkenfeld-nospam at wolke7.net
Sun Apr 24 12:18:01 EDT 2005
Diez B. Roggisch wrote:
> Reinhold Birkenfeld wrote:
>
>> Diez B. Roggisch wrote:
>>>> class Foo(type):
>>>> def __new__(cls, name, bases, dict):
>>>>
>>>> for k,v in [(k, v) for k,v in dict.items() if callable(v)]:
>>>> cls.wrap(k,v,cls.get_directives(v), dict)
>>>>
>>>> return super(Foo, self).__new__(self, name, bases, dict)
>>>
>>> There is a confusion of self and cls above - rename self with cls.
>>
>> And remove the first argument to __new__.
>
> Ehm, no, I don't think so. The code was copied and pasted from a working
> metaclass (at least I hope so...), and in the original code a underscore
> was used for the first argument. I've been following that bad habit for a
> while but recently started to be more following to the established
> conventions. So I rewrote that code on the fly.
Oh yes. I forgot that __new__ is a staticmethod anyhow.
Reinhold
More information about the Python-list
mailing list