Class definition attribute order
tjreedy at udel.edu
Tue Aug 5 07:47:40 CEST 2008
Michele Simionato wrote:
> On Aug 5, 4:38 am, "Gabriel Genellina":
>> 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?
> Yep. See http://stacktrace.it/articoli/2008/01/metaclassi-python-3000
> (I am working on an English translation these days,
> but for the moment you can use Google Translator).
Bfiefly, as I understood the discussion some months ago: In 2.x, the
class body is executed in a local namespace implemented as a normal dict
and *then* passed to the metaclass. In 3.0, the metaclass gets brief
control *before* execution so, among other possibilities, it can
substitute an (insertion) ordered dict for the local namespace. I will
leave the details to Michele's article and its eventual translation.
More information about the Python-list