Re: Initializing an attribute that needs the object

2006-06-03 Thread Bruno Desthuilliers
David Pratt a écrit : David, please, don't top-post (fixed) > > Bruno Desthuilliers wrote: > (snip) >> >> Hint : Python classes are objects too. >> >> >> class Factory(object): >>def __init__(self, handler_class): >> self.handler = handler_class(self) >> >> class SomeHandler(object): >

Re: Initializing an attribute that needs the object

2006-06-03 Thread David Pratt
Hi John. Thank you for the tips and the link. This is helpful. Many thanks. Regards David > A new-style class is one which inherits ultimately from the type that is > called "object". > > class NewStyleClass(object): > pass > > class OldStyleClass(): > pass > > Docs are a bit u

Re: Initializing an attribute that needs the object

2006-06-02 Thread John Machin
On 3/06/2006 9:17 AM, David Pratt **TOPPOSTED**: > 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? More precisely, don't use object when you are subclassing. > Where will I fi

Re: Initializing an attribute that needs the object

2006-06-02 Thread David Pratt
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 Desthu

Re: Initializing an attribute that needs the object

2006-06-02 Thread Bruno Desthuilliers
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 (

Re: Initializing an attribute that needs the object

2006-06-02 Thread David Pratt
My apologies. What I meant to write was this class Factory def __init__(self, handler): David Pratt wrote: > Hi Marco. Thanks for your reply. I am providing the handler with the > factory instance as I have shown. This is how my code currently works. > What I am trying to figure out

Re: Initializing an attribute that needs the object

2006-06-02 Thread David Pratt
Hi Marco. Thanks for your reply. I am providing the handler with the factory instance as I have shown. This is how my code currently works. What I am trying to figure out is how to possibly provide the handler in the constructor when it needs the factory instance. This would give me some better

Re: Initializing an attribute that needs the object

2006-06-02 Thread Marco Giusti
On Fri, Jun 02, 2006 at 06:15:28PM -0300, David Pratt wrote: >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 inst