Re: Inheritance problem

2008-11-05 Thread Mr . SpOOn
On Wed, Nov 5, 2008 at 6:59 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote: > You need to call the __init__ of NoteSet inside Scale, as otherwise the > instance isn't properly initialized. Thanks, solved. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem

2008-11-05 Thread Diez B. Roggisch
Mr.SpOOn wrote: > Hi, > I have a problem with this piece of code: > > > class NoteSet(OrderedSet): > def has_pitch(self): > pass > def has_note(self): > pass > > class Scale(NoteSet): > def __init__(self, root, type): > self.append(root) > self.type =

Re: Inheritance problem

2007-05-09 Thread Jason
On May 9, 12:09 pm, [EMAIL PROTECTED] wrote: > I'm trying to solve a problem using inheritance and polymorphism in > python 2.4.2 > > I think it's easier to explain the problem using simple example: > > class shortList: > > def __init__(self): > > self.setList() > > def setList(self

Re: Inheritance problem

2007-05-09 Thread attn . steven . kuo
On May 9, 11:33 am, Bjoern Schliessmann wrote: > [EMAIL PROTECTED] wrote: > > class longList(shortList): > > > def __init__(self): > > > shortList.setList() > > > self.setList() > > Addition: Always call the base class __init__ in your constructor if > there exists one, i. e. >

Re: Inheritance problem

2007-05-09 Thread Bjoern Schliessmann
[EMAIL PROTECTED] wrote: > class longList(shortList): > > def __init__(self): > > shortList.setList() > > self.setList() Addition: Always call the base class __init__ in your constructor if there exists one, i. e. class longList(shortList) def __init__(self): s

Re: Inheritance problem

2007-05-09 Thread Neil Cerutti
On 2007-05-09, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I'm trying to solve a problem using inheritance and > polymorphism in python 2.4.2 It's not an inheritance problem, it's a notation problem. Python uses explicit 'self', saving you the trouble of devising a naming convention for data me

Re: Inheritance problem?

2006-01-06 Thread Scott David Daniels
KraftDiner wrote: > So ok I've written a piece of code that demonstrates the problem. > Can you suggest how I change the Square class init? > > class Shape(object): > def __init__(self): > print 'MyBaseClass __init__' > > class Rectangle(Shape): > def __init__(self): > #

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
KraftDiner a écrit : > So ok I've written a piece of code that demonstrates the problem. > Can you suggest how I change the Square class init? > > class Shape(object): > def __init__(self): > print 'MyBaseClass __init__' > > class Rectangle(Shape): > def __init__(self):

Re: Inheritance problem?

2006-01-06 Thread KraftDiner
So ok I've written a piece of code that demonstrates the problem. Can you suggest how I change the Square class init? class Shape(object): def __init__(self): print 'MyBaseClass __init__' class Rectangle(Shape): def __init__(self): super(self.__clas

Re: Inheritance problem?

2006-01-06 Thread Mike Meyer
Xavier Morel <[EMAIL PROTECTED]> writes: > Pierre Barbier de Reuille wrote: >> Well, I would even add : don't use super ! >> Just call the superclass method : >> MyClass.__init__(self) >> Simon Percivall a écrit : >>> Don't use self.__class__, use the name of the class. > Bad idea if you're using n

Re: Inheritance problem?

2006-01-06 Thread Xavier Morel
Pierre Barbier de Reuille wrote: > Xavier Morel a écrit : >> Pierre Barbier de Reuille wrote: >> >>> Well, I would even add : don't use super ! >>> Just call the superclass method : >>> >>> MyClass.__init__(self) >>> >>> >>> >>> Simon Percivall a écrit : >>> Don't use self.__class__, use the n

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
Xavier Morel a écrit : > Pierre Barbier de Reuille wrote: > >> Well, I would even add : don't use super ! >> Just call the superclass method : >> >> MyClass.__init__(self) >> >> >> >> Simon Percivall a écrit : >> >>> Don't use self.__class__, use the name of the class. >>> > Bad idea if you're usi

Re: Inheritance problem?

2006-01-06 Thread Xavier Morel
Pierre Barbier de Reuille wrote: > Well, I would even add : don't use super ! > Just call the superclass method : > > MyClass.__init__(self) > > > > Simon Percivall a écrit : >> Don't use self.__class__, use the name of the class. >> Bad idea if you're using new-style classes with a complex inh

Re: Inheritance problem?

2006-01-06 Thread Pierre Barbier de Reuille
Well, I would even add : don't use super ! Just call the superclass method : MyClass.__init__(self) Simon Percivall a écrit : > Don't use self.__class__, use the name of the class. > -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem?

2006-01-06 Thread Simon Percivall
Don't use self.__class__, use the name of the class. -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem ?

2005-08-24 Thread tooper
Not always easy to follow but great ! Using __str__ instead of __repr__ makes it work also with old style (thanks to Simon Brunning for suggesting it, and with your link I even now understand why !) -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem ?

2005-08-24 Thread jitya
The stuff on Descriptor.htm was really good . Thanks -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem ?

2005-08-24 Thread tooper
Thanks, at least makes it running ! I'll have to teach myself to move to this new style classes by default anyway... -- http://mail.python.org/mailman/listinfo/python-list

Re: Inheritance problem ?

2005-08-24 Thread jitya
tooper wrote: > Hello all, > > I'm trying to implement a common behavior for some object that can be > read from a DB or (when out of network) from an XML extract of this DB. > I've then wrote 2 classes, one reading from XML & the other from the > DB, both inheritating from a common one where I wan

Re: Inheritance problem ?

2005-08-24 Thread db
On Wed, 24 Aug 2005 03:34:36 -0700, tooper wrote: > Hello all, > > I'm trying to implement a common behavior for some object that can be > read from a DB or (when out of network) from an XML extract of this DB. > I've then wrote 2 classes, one reading from XML & the other from the > DB, both inhe

Re: inheritance problem with 2 cooperative methods

2004-12-03 Thread Dan Perl
This is almost the same code as Greg's with the only difference being that test for configuration having been done. But the test is unnecessary. I don't see how setConfig could be invoked in the super of the base class (A), so such a test would be relevant only in subclasses, if they DO invoke

Re: inheritance problem with 2 cooperative methods

2004-12-03 Thread David Fraser
Dan Perl wrote: Here is a problem I am having trouble with and I hope someone in this group will suggest a solution. First, some code that works. 3 classes that are derived from each other (A->B->C), each one implementing only 2 methods, __init__ and setConfig.

Re: inheritance problem with 2 cooperative methods

2004-12-02 Thread Dan Perl
Thank you very much, Greg, that does the job! Somehow I couldn't see it and I needed someone to point out to me. Dan "Greg Ewing" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Dan Perl wrote: >> So far, so good! But let's assume that I want to change the __init__ >> methods s

Re: inheritance problem with 2 cooperative methods

2004-12-02 Thread Greg Ewing
Dan Perl wrote: So far, so good! But let's assume that I want to change the __init__ methods so that they take a configuration as an argument so the objects are created and configured in one step, like this: alpha = A(config) One way would be to make the setConfig call only in the root class, an