Order in metaclass
Michael Hudson
mwh at python.net
Wed Oct 13 07:22:24 EDT 2004
bokr at oz.net (Bengt Richter) writes:
> >Nicolas Fleury wrote:
> >
> >> In the following example:
> >>
> >> class MyMetaclass(type): pass
> >> class MyBaseType(object): __metaclass__ = MyMetaclass
> >> class MyType(MyBaseType):
> >> x = 4
> >> y = 5
> >> z = 6
> >>
> >> Is there any way to modify MyMetaclass to keep the order of x,y,z
> >> somewhere?
> >
[snip]
>
> Or, an ugly hack that might work for a while, depending on how
> co_names is really generated. It seems in order of occurrence
> (including right hand sides of assignment, but still top down) ...
I don't know whether to laugh or cry! Nice one.
Cheers,
mwh
--
<lament> Slashdot karma, unfortunately, is not real karma, because
it doesn't involve the death of the people who have it
-- from Twisted.Quotes
More information about the Python-list
mailing list