beginner, idomatic python 2
Bruno Desthuilliers
bruno.42.desthuilliers at wtf.websiteburo.oops.com
Fri Aug 31 04:49:56 EDT 2007
bambam a écrit :
> "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'?
>
Mmm... Most CS experts don't really agree on this, and I'm certainly not
one (expert). So I won't even try to explain it by myself, and let you
google for "type system", "static typing", "dynamic typing", "duck
typing" etc...
Now what I meant here is that in Python, you don't have to make class B
inherit from class A to let you use an instance of B where an instance
of A was expected - all you need is that both objects share the set of
attributes and methods you're going to use. Inheritence is only useful
for sharing common code.
HTH
More information about the Python-list
mailing list