metaclasses (beginner question)

Laszlo Nagy gandalf at designaproduct.biz
Wed Feb 21 10:41:12 EST 2007


> Without looking into the details -- the (subclass of) type is meant to be
> the class of the class, or the other way round, your normal classes are
> instances of (a subclass of) type. You determine the factory Python uses to
> make a class by adding
>
> __metaclass__ = factory
>
> to the class body, so you'll probably end with something like
>
> class ProducerHandlerType(type):
>     # your code 
>
> class A:
>     __metaclass__ = ProducerHandlerType
>
> The subclasses of A will now invoke your customised metaclass machinery.
>   
Thanks, I missed that. I added the __metaclass__ line and it worked like 
a charm.

  Laszlo




More information about the Python-list mailing list