Making classes from Metaclasses globally available

Peter Otten __peter__ at
Wed Jun 16 09:38:16 CEST 2004

Jean-François Doyon wrote:

> I'm using MetaClasses to create classes.
> How do I make these new classes "globally" available?

As far as I can see, your problem has nothing to do with metaclasses.

>>> globals()["foo"] = 1
>>> foo

Substitute 1 in the above with your new class, and there you are. Note,
however, that dynamically inserting variables is not the best programming
practice. When you don't know the variable name in advance, what would be
the benefit of being able to access the object via its identifier?


More information about the Python-list mailing list