Re: metaclasses (beginner question)

2007-02-22 Thread James Stroud
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 >

Re: metaclasses (beginner question)

2007-02-21 Thread Laszlo Nagy
> 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

Re: metaclasses (beginner question)

2007-02-21 Thread Peter Otten
Laszlo Nagy wrote: > I would like to create a hierarchy classes, where the leaves have a > special attribute called "producer_id". In addition, I would like to > have a function that can give me back the class assigned to any > producer_id value. I tried to implement this with a metaclass, but I >

metaclasses (beginner question)

2007-02-21 Thread Laszlo Nagy
Hello, I would like to create a hierarchy classes, where the leaves have a special attribute called "producer_id". In addition, I would like to have a function that can give me back the class assigned to any producer_id value. I tried to implement this with a metaclass, but I failed. Pleas