Question on metaclasses

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sun Apr 24 10:30:13 EDT 2005


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__.

Reinhold



More information about the Python-list mailing list