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
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 =
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
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.
>
[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
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
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):
> #
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):
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
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
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
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
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
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
Don't use self.__class__, use the name of the class.
--
http://mail.python.org/mailman/listinfo/python-list
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
The stuff on Descriptor.htm was really good .
Thanks
--
http://mail.python.org/mailman/listinfo/python-list
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
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
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
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
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.
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
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
24 matches
Mail list logo