Find class attributes creation order

Cédric Lucantis omer at no-log.org
Mon Jun 23 18:08:29 CEST 2008


Le Monday 23 June 2008 17:53:07 Marcob, vous avez écrit :
> Let's see these simple classes:
>
>     class base_foo()
>          pass
>
>     class foo(base_foo):
>          a=1
>          b={}
>          c="zz"
>
> I would like to find class foo attributes creation order.
> Using __metaclass__ is not of help because special method __new__
> receive attrs as a dictionary and so the order isn't preserved. Any
> other idea?
>

I don't really understand what you want, but __new__ may accept any kind of 
attributes, this is your choice. You can use named params or a vararg list 
(which will preserve params order).

But in your example you're only using class attributes, so __new__ is not 
involved and they are just created once for all in the order you write them: 
a, b, c.

-- 
Cédric Lucantis



More information about the Python-list mailing list