setattr in class

Christian Heimes lists at cheimes.de
Fri Sep 12 11:21:57 EDT 2008


Bojan Mihelac wrote:
> I guess A class not yet exists in line 4. Is it possible to achive
> adding dynamic attributes without using exec?

Correct, the class doesn't exist until the end of the class body. You 
can either do it outside the class definition or you can use a metaclass.

Christian




More information about the Python-list mailing list