Abstract class

Roy Smith roy at panix.com
Sun Sep 14 13:56:44 EDT 2008


In article <mailman.1008.1221408214.3487.python-list at python.org>,
 Mr.SpOOn <mr.spoon21 at gmail.com> wrote:

> I have to manage many elements of music such as notes, intervals,
> scales, chords and so on. All these elements share properties and
> behavior, so what I want to do is an abstract class "Note" and other
> subclasses, for example "NaturalNote", "FlatNote", "SharpNote" etc.

What properties or behaviors does SharpNote have which NaturalNote doesn't?  
Unless there is some new behavior, you don't need subclasses.

Are you also going to have DoubleSharpNote and DoubleFlatNote?

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?



More information about the Python-list mailing list