metaclasses (beginner question)
James Stroud
jstroud at mbi.ucla.edu
Thu Feb 22 15:17:01 EST 2007
Peter Otten wrote:
> 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.
This is the most perfectly succinct description of the __metaclass__
attribute I have ever seen. Beautiful.
James
More information about the Python-list
mailing list