metaclass : parse all class once before doing anything else ?
Diez B. Roggisch
deets at nospam.web.de
Sat Jul 29 05:17:21 EDT 2006
Laurent Rahuel schrieb:
> I got a metaclass named Foo
I have the impression that you are not talking about a meta-class, but a
normal class here.
> Then I got two others classes:
>
> class Bar(Foo):
> pass
>
> class Baz(Foo):
> pass
>
> I know how to add some attrs, methods to Bar and Baz when the module is
> loaded but I need to do something more :
>
> Before adding anything to these classes,
> 1 - I need to parse all defined Foo classes
> 2 - "sort" them
> 3 - parse this sorted list to add attrs and methods.
>
> This seems to be really to clever for me ;-(
>
> Any idea ?
Why do you want to do this? It is in that way not possible - python has
no preprocessing step that would allow this.
I suggest you explain to us what you are after here, and then we might
come up with a solution.
Diez
More information about the Python-list
mailing list