Re: changing how instances are "created"

2005-06-12 Thread John Roth
"newseater" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> > class Creator >> > def createInstance(cls, *args, **kwargs): >> > anewinstance = cls.__new__(cls, *args, **kwargs) >> > anewinstance.__init__(*args, **kwargs) >> > >> > return anewinstance >> > createInstance = staticmet

Re: changing how instances are "created"

2005-06-12 Thread newseater
> > A staticmethod does not take a cls argument. It is essentially just a > function that is attached to a class. yes i know of that difference... but one cannot easily override a class method in a supclass.. as calling super then make the cls variable point to the super class class rather than th

Re: changing how instances are "created"

2005-06-12 Thread newseater
> > class Creator > > def createInstance(cls, *args, **kwargs): > > anewinstance = cls.__new__(cls, *args, **kwargs) > > anewinstance.__init__(*args, **kwargs) > > > > return anewinstance > > createInstance = staticmethod(createInstance) > > > > > > can anyone help?? > > __new__ is the proper way t

Re: changing how instances are "created"

2005-06-12 Thread Robert Kern
newseater wrote: > > Robert Kern wrote: > >>newseater wrote: >> >>>Hello. I need to be able to control how objects are created. Sometimes >>>when creating an object, i want to reuse another object instead. I've >>>searched for factory method implementations and singleton >>>implementations. They

Re: changing how instances are "created"

2005-06-12 Thread John Roth
"newseater" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello. I need to be able to control how objects are created. Sometimes > when creating an object, i want to reuse another object instead. I've > searched for factory method implementations and singleton > implementations. Th

Re: changing how instances are "created"

2005-06-12 Thread newseater
Robert Kern wrote: > newseater wrote: > > Hello. I need to be able to control how objects are created. Sometimes > > when creating an object, i want to reuse another object instead. I've > > searched for factory method implementations and singleton > > implementations. They were too much of a hac

Re: changing how instances are "created"

2005-06-12 Thread Robert Kern
newseater wrote: > Hello. I need to be able to control how objects are created. Sometimes > when creating an object, i want to reuse another object instead. I've > searched for factory method implementations and singleton > implementations. They were too much of a hack! > > My first attempt of doi

changing how instances are "created"

2005-06-12 Thread newseater
Hello. I need to be able to control how objects are created. Sometimes when creating an object, i want to reuse another object instead. I've searched for factory method implementations and singleton implementations. They were too much of a hack! My first attempt of doing this was to play around wi