Can I inherit member variables?

Bruno Desthuilliers onurb at xiludom.gro
Fri Sep 22 05:44:46 EDT 2006


Gabriel Genellina wrote:
> At Thursday 21/9/2006 09:14, Bruno Desthuilliers wrote:
> 
>> > When you construct an object instance, it is of a certain type from
>> that
>> > precise moment, and you can't change that afterwards.
>>
>> Err... Actually, in Python, you can. It's even a no-brainer.
> 
> Yes, but trying to explain that to a beginner would just make things
> worse...

Agreed. But this newsgroup is not only read by beginners, and the last
part of your statement happens to be false. The first part is ok, and
would have been enough IMHO.

> You must grab the inheritance concept first.

Mmm... It's clear that the OP didn't get the concept right...

OTHO, inheritance (not subtyping...) is a very overrated concept IMHO
and really not central to OO - at least with dynamically typed languages
(or using type inference). It's in fact nothing more than a special case
of composition/delegation. What's really important here is polymorphic
dispatch, which shouldn't (and, in Python, doesn't) rely on
implementation inheritance.

I really think that insisting on implementation inheritance is the wrong
way to teach OO. But I may not be a good teacher !-)


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list