beginner, idomatic python 2

Neil Cerutti horpner at yahoo.com
Thu Aug 30 22:24:50 EDT 2007


On 2007-08-31, bambam <david at asdf.asdf> wrote:
> "Bruno Desthuilliers"
> <bruno.42.desthuilliers at wtf.websiteburo.oops.com> wrote in
> message news:46d2ba7a$0$430$426a74cc at news.free.fr...
>> As a side note, in Python, inheritance ... ... should usually
>> not be used for typing.
>
>:~(
> I'm sorry, I don't even know what that means... The code I have
> inherited from someone only a little more knowledgeable than
> me, and is still full of development artifacts anyway.
>
> The Pwr and Psp classes inherit from the Device class not
> neccessarily because that is a Good Thing, more because the
> development process led to them being thought of that way. All
> devices have a mixture of common and differing attributes.
>
> What is 'typing'?

In a language with strict types, you may need to make a set of
classes all inherit from one base class simply in order to get
the code to compile.  A common example is a set of classes that
all behave like file streams.

You don't need to do this in Python. Simply have the object
provide the right methods and you are done.

-- 
Neil Cerutti



More information about the Python-list mailing list