multiple inheritance

2005-06-09 Thread newseater
i don't know how to call methods of super classes when using multiple inheritance. I've looked on the net but with no result :( class a(object): def foo(self): print "a" class b(object): def foo(self): print "a" class c(a,b) def foo(self): super( a).foo()

Re: multiple inheritance

2005-06-09 Thread newseater
if I only use the super() construct it seems not to call B class A(object): def foo(self): print "a" class B(object): def foo(self): print "b" class C(A,B): def foo(self): print "c" super(C,self).foo() c

Re: multiple inheritance

2005-06-09 Thread newseater
how nice! is this due to a linearization taking place of A and B when compiling C ? is this a 'feature' of the language or its actual semantics to behave like this? > class IFoo(object): > def foo(self): > pass > > class A(IFoo): > def foo(self): > print "a" > supe

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

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 > > implemen

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 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