Inheritance problem

Mr.SpOOn mr.spoon21 at gmail.com
Wed Nov 5 12:48:24 EST 2008


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 = type
        ScaleType(scale=self)

OrderedSet is an external to use ordered sets. And it has an append
method to append elements to the set.

When I try to create a Scale object:

s = Scale(n, '1234567')  # n is a note

I get this error:

Traceback (most recent call last):
  File "notes.py", line 276, in <module>
    s = Scale(n, '1234567')
  File "notes.py", line 243, in __init__
    self.append(root)
  File "ordered_set.py", line 78, in append
    self._insertatnode(self._end.prev, element)
AttributeError: 'Scale' object has no attribute '_end'

I can't understand where the error is.
Can you help me?

Thanks,
Carlo



More information about the Python-list mailing list