Making classes from Metaclasses globally available

Stephan Diehl stephan.diehlNOSPAM at gmx.net
Wed Jun 16 03:52:24 EDT 2004


Jean-François Doyon wrote:

> 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', (), {})
> 

Just do

class Klass(object):
    __metaclass__ = MetaClass

Cheers

Stephan



More information about the Python-list mailing list