Making classes from Metaclasses globally available

Jean-François Doyon jfdoyon at methane.ca
Wed Jun 16 00:28:46 EDT 2004


Hello,

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), (),
{'schema':list,'__init__':MapServerClassInit})

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?

Thanks,
J.F.





More information about the Python-list mailing list