massimo s. wrote:

> On 13 Feb, 12:46, Peter Otten <[EMAIL PROTECTED]> wrote:
>> Well, what problems ocurring with
>>
>> class A: pass
>> class B: pass
>> class C(A, B): pass
>>
>> could be avoided by writing
>>
>> class A: pass
>> class B(A): pass
>> class C(B): pass
>>
>> instead? Classes have to be designed for subclassing, so essentially you
>> get two interfaces, one for subclasses and one for client code instead of
>> just the latter. A more relevant mantra governing inheritance is "Flat is
>> better than nested".
> 
> I am truly getting lost. Are you saying that doing A-->B(A)--C(B) is
> better than C(A,B)? And isn't the former thing nested? Or are you
> saying that C(A,B) is better than A,B(A),C(B)? And in both cases:why?

Neither. I wanted to express that I don't buy the "mantra" you mentioned
above. Just because it uses only single inheritance code doesn't become
magically more robust. Use whatever works best to solve the actual problem.
 
> And why "classes have to be designed for subclassing"? I often do
> classes that are not thought to be subclassed.

That's fine. If (and only if) you expect a class to be subclassed you better
spend some thought on what methods should be overriden etc. This increases
the effort spent on the class significantly. Distinct classes are often
easier to write and maintain.

Hope-I'm-clear-this-time,
Peter

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to