Making classes from Metaclasses globally available

Jean-François Doyon jfdoyon at
Wed Jun 16 06:28:46 CEST 2004


I'm using MetaClasses to create classes.

How do I make these new classes "globally" available?

I probably just have to assign them to something magic, but I can't seem to
figure out which one.

if I do:

MetaClass('Klass', (), {})

The resulting class needs to be assigned to something:

    myclass = MetaClass('Klass', (), {})

The problem is that I'm  looping and don't know in advance how many classes
there will be.

So right now I have something like:

msclasses[clsname] = MapServerMetaClass(str(clsname), (),

inside a loop.

Problem is I really don't want to have the classes stuck inside that dict.
I want them "globally" available as if I had simply made a "class"
declaration at the top of the file.

Any ideas or suggestions?


More information about the Python-list mailing list