Hi Bruno. This is certainly what I was missing. Thank you. I am afraid I am behind the times with use of object. Will I only use object when I am not subclassing? Where will I find a document that provides info on the use of object in new style classes? Many thanks.
Regards, David Bruno Desthuilliers wrote: > David Pratt a écrit : >> Hi. I want to have different handlers to do perform logic. The problem >> is the Handler requires an instance of the factory since it will use its >> own methods in conjunction with methods of the factory. >> >> Once I have got a Factory instance I can give it a new handler (see >> below). It would be more flexible if I could provide a handle in >> constructor - but how to do this when it requires the object itself. > > Hint : Python classes are objects too. > >> class Factory: > > Do yourself a favour : use new-style classes. > > class Factory(object): > def __init__(self, handler_class): > self.handler = handler_class(self) > > class SomeHandler(object): > def __init__(self, factory): > self.factory = factory > > f = Factory(SomeHandler) -- http://mail.python.org/mailman/listinfo/python-list