[Python-Dev] Unifying Long Integers and Integers: baseint

Nick Coghlan ncoghlan at iinet.net.au
Thu Aug 12 09:10:55 CEST 2004


Dmitry Vasiliev wrote:

> Is it a good time to consider the entrie tree of ALL types then?

Please, no. One of the best things about Python is that, for most 
purposes, you can get the appropriate reaction from the standard library 
simply by providing the relevant magic methods (e.g. __iter__ if you 
want to be treated like a sequence).

Normal class inheritance means you are inheriting the *whole* interface, 
as well as the implementation of any parts you don't override.

So 'sequence' for instance, couldn't have any methods or do much of 
anything, without causing potentially undesirable behaviour.

About the only exception that makes any sense to me is for exceptions, 
where using inheritance for classification seems to be universal 
practice in all languages with exceptions (since 'catch X' generally 
means catch X, or any of its subclasses). (Bad pun noted, and not avoided).

Localised type hierarchies where it is useful, OK. Inheriting from 
object as a way to say 'new-style class please', OK. But please, please, 
please, lets keep interface introspection the dominant way of 
determining what can be done with a particular object. Creating a 'grand 
hierarchy of everything' runs directly counter to that goal.

Regards,
Nick.


-- 
Nick Coghlan               |  Eugene, Oregon
Email: ncoghlan at email.com  |             USA


More information about the Python-Dev mailing list