Adding a list of descriptors to a class
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Tue Aug 7 12:43:21 EDT 2007
On Tue, 07 Aug 2007 09:25:32 -0700, Bob B. wrote:
> Ok, that "exec" is an ugly hack. There's gotta be someway to plop
> this straight into the class's __dict__ without doing that, but when I
> try adding self.__class__.__dict__[attr] = MyDesc(attr) in MyClass's
> __init__ method, I get the error: "TypeError: 'dictproxy' object does
> not support item assignment"
Does ``setattr(self.__class__, attr, MyDesc(attr))`` work?
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list