Class definition attribute order

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Aug 4 22:38:23 EDT 2008


En Fri, 01 Aug 2008 23:47:42 -0300, Benjamin <musiccomposition at gmail.com>  
escribió:
> On Aug 1, 6:23 pm, Andrew Lentvorski <bs... at allcaps.org> wrote:
>> How do I determine the order of definition of class attributes?
>>
>> For example, if I have a class
>>
>> class Test(object):
>>      y = 11
>>      x = 22
>>
>> How do I tell that y was defined before x?
>
> You wait until Python 3.0 where you can do this sort of thing with
> metaclasses.

So the namespace that the metaclass receives when the class is created,  
will be some kind of ordered dictionary?
Metaclasses are available for a long time ago, but the definition order is  
lost right at the start, when the class body is executed. Will this step  
be improved in Python 3.0 then?

-- 
Gabriel Genellina




More information about the Python-list mailing list