[Tutor] Metaclass confusion...

2011-04-19 Thread Modulok
List, I've been messing with metaclasses. I thought I understood them until I ran into this. (See code below.) I was expecting the generated class, 'Foo' to have an 'x' class-level attribute, as forced upon it by the metaclass 'DracoMeta' at creation. Unfortunately, it doesn't and I don't know why

Re: [Tutor] Metaclass confusion...

2011-04-19 Thread Peter Otten
Modulok wrote: > List, > > I've been messing with metaclasses. I thought I understood them until I > ran into this. (See code below.) I was expecting the generated class, > 'Foo' to have an 'x' class-level attribute, as forced upon it by the > metaclass 'DracoMeta' at creation. Unfortunately, it

Re: [Tutor] Metaclass confusion...

2011-04-20 Thread Modulok
Peter, >> ... the class, i. e. the instance of the metaclass with all its attributes >> has already been created by the type.__new__() method. If you move the >> manipulation of the members dict into a custom __new__() method you get >> the desired behaviour... Thank you! You've solved my problem