Abstract class

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sun Sep 14 11:33:20 EDT 2008


Mr.SpOOn a écrit :
> Hi,
> I'm going to work on a project to represent some musical theory in
> Python, in an object oriented way.
> 
> 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.
> 
> The idea is not original, I read it in some papers where they talk
> about an implementation in smalltalk.
> 
> I want to use Python (of course) and I'd like to know what is the
> practice in such a case. I mean, in python there aren't abstract
> classes, but I read about some way to emulate the same behavior.
> 
> What do you suggest me?

Conceptually, an abstract class is a class that is not intented to be 
instanciated directly but used as a parent class. The simplest way to 
get such behaviour is to just write your base class and avoid 
instanciating it.



More information about the Python-list mailing list