Reference class in class creation

Duncan Booth duncan.booth at invalid.invalid
Tue Nov 21 14:14:17 CET 2006


Gregor Horvath <gh at gregor-horvath.com> wrote:

> Diez B. Roggisch schrieb:
> 
>> Anything wrong with:
>> 
>> class Foo(object):
>>    pass
>> 
>> Foo.a = Foo
>> 
>> ?
> 
> Thanks.
> The problem with this is that there is also metaclass hacking involved
> which relies on "a" 's creation in the class body. In your suggestion
> "a" is not present when __new__ of the metaclass is called.
> 
The class doesn't exist until the metaclass has created it, so you can't 
expect to have any references to it.

You've told us that what you are trying to do doesn't work, but you haven't 
said why you want to do it. What is the problem you are really trying to 
solve?



More information about the Python-list mailing list