Bruno Desthuilliers <[EMAIL PROTECTED]> writes: > Rafe a écrit : >> On Nov 20, 2:06 pm, Arnaud Delobelle <[EMAIL PROTECTED]> wrote: > (snip) >>> >>> Or (better IMHO) you can make types register themselves with the factory >>> function (in which case it would have some state so it would make more >>> sense to make it a factory object). >>> >> >> Can you elaborate on what you mean by 'register' with the factory >> function? > > I think Arnaud means something like: > > # baselib.py > class Base(object): > _registry = {} > > @classmethod > def register(cls, subclass): > cls._registry[subclass.__name__] = subclass > > @classmethod > def get_class(cls, classname): > return cls._registry[classname] > > > # typelib.py > from baselib import Base > > class Sub(Base): > pass > > Base.register(Sub)
That's what I meant. Sorry Rafe I missed your follow-up. -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list