getting a reference to a class inside its definition
dan
dan at eevolved.com
Mon Jun 18 23:16:31 EDT 2001
Pearu Peterson wrote:
> On Mon, 18 Jun 2001, dan wrote:
>
>> class SomeClass:
>> pass
>> SomeClass.clsref = SomeClass
>
> If it will be used as
>
>>>> SomeClass().clsref
>
> then it is equivalent to
>
>>>> SomeClass().__class__
>
> So, why would you want .clsref attribute if .__class__ is
> available already?
>
> Pearu
So my question is why answer my question? ;)
I'm building a factory class of other classes. One of the factories is a
factory of itself... It's also a baseclass, which is why I need it to be an
attribute so it can be overloaded later. I hope this satisfies your
curiosity :)
Dan
More information about the Python-list
mailing list