[Python-3000] Builtin iterator type

Aaron Bingham bingham at cenix-bioscience.com
Thu Nov 23 08:58:38 CET 2006


Nick Coghlan wrote:

> Aaron Bingham wrote:
>
>> Bill Janssen wrote:
>>
>>>> Java interfaces are very useful, however. Java programming seems to 
>>>> be less and less about inheritance and more and more about 
>>>> implementing interfaces; at least it does amongst Java programmers 
>>>> with taste :-)
>>>>    
>>>
>>> It seems to me that that's where Python has a real advantage.  With
>>> real support for multiple inheritance, Python "interfaces" could be
>>> real classes (either like real Java classes or Java abstract classes),
>>> perhaps providing default implementations.  You get the goodness of
>>> mix-ins, along with interface communication.
>>>
>> I agree.  In Java, interfaces are necessary because multiple 
>> inheritance is not supported.  I see no good reason to add an 
>> additional language mechanism for interfaces when multiple 
>> inheritance would do the job, AFAICT.
>
>
> Just because multiple inheritance is *possible* in Python, don't make 
> the mistake of thinking that it is straight forward. Aside from mixin 
> classes that themselves inherit directly from object, multiple 
> inheritance can get very messy outside of tightly controlled type 
> hierarchies (cooperative calls in particular can become a nightmare). 
> This flies in the face of Python's use as a glue language to tie 
> multiple components together (particularly given the problem that some 
> of the elements being integrated may come from environments that 
> *don't* support multiple inheritance, like the JVM).

It's true that multiple inheritance in Python can get quite messy.  
Python lacks two mechanisms to control this complexity that are, AFAIK, 
only available in Eiffel: renaming and hiding of superclass attributes 
and methods.  Implementing these mechanisms in a dynamically typed 
languages is AFAICT impossible.  I won't go into a detailed explanation 
here unless someone requests it.

Regards,

-- 
--------------------------------------------------------------------
Aaron Bingham
Senior Software Engineer
Cenix BioScience GmbH
--------------------------------------------------------------------



More information about the Python-3000 mailing list