Metaclasses and class variables

Christopher Subich spam.csubich+block at block.subich.spam.com
Thu Aug 4 15:34:50 CEST 2005


Jan-Ole Esleben wrote:
> class Meta(type):
>   def __new__(cls, name, bases, d):
>     d['classvar'] = []
>     return type.__new__(cls, name, bases, d)

The problem is that __new__ is called upon object construction, not 
class definition, but you're trying to set the class variables at 
definition-time.



More information about the Python-list mailing list