Abstract class

Mr.SpOOn mr.spoon21 at gmail.com
Sun Sep 14 20:55:02 CEST 2008

Gary Harron:
>I believe you are mixing up class *inheritance* and *abstract* classes.

>Class inheritance (with Python has has for years) is how one class inherits >behavior/properties/attributes from another class.  The class being inherited from is >called the base class.  This is probably what you want.

Well, I know the difference between an abstract class and an inherited
one. The idea was to create a main class Note, with abstract methods,
and implement these methods in the other classes.

On Sun, Sep 14, 2008 at 7:56 PM, Roy Smith <roy at panix.com> wrote:
> What properties or behaviors does SharpNote have which NaturalNote doesn't?
> Unless there is some new behavior, you don't need subclasses.

Well, from a SharpNote I can obtain the relative NaturalNote. So if I
have a C# I can call

natural('C#')  and get 'C'

While in the class NaturalNote I don't need such a method, but I need
two methods to get the sharped and flatted version

> Are you also going to have DoubleSharpNote and DoubleFlatNote?

Yes, that's an option.

> Consider the following code:
> note1 = SharpNote("E4")
> note2 = NaturalNote("F4")
> if note1 == note2:
>   print "the same note"
> else
>   print "different notes"
> what should it print?

Well, that's not so simple. The idea is that I use a notation (A, B,
C, D...) and an integer (a distance expressed in semitones) to
identify a note.

Anyway, I think I need an abstract class. Or not?

More information about the Python-list mailing list