A Python 3000 Question

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Tue Oct 30 10:22:58 CET 2007

brad a écrit :
> Rob Wolfe wrote:
>> I wonder why people always complain about `len` function but never
>> about `iter` or `pprint.pprint`? :)
> Not complaining. len is simple and understandable and IMO fits nicely 
> with split(), strip(), etc... that's why I used it as an example, but 
> list(), etc. could be used as examples as well:
> a_string.list() instead of list(a_string)

Oh, fine. And a_string.tuple(), a_string.int(), a_string.this(), 
a_string.that() etc ?

In case you don't know, list is a type, not a function !-)

>> And to answer the question. In OO programming generic functions
>> are no less important than classes and objects.
> Do they not take away from the OOness of the overall language

Why so ?

> and 
> introduce inconsistencies?

The monotonic approach to callables in Python (I mean: functions are 
callable objects, classes are callable objects, so instanciation and 
function call have the exact same syntax - which let you decouple 
interface from implementation) is another way to be consistent. because 
you can switch from type to factory function (or from closure to 
callable object, etc) back and forth without breaking client code.

More information about the Python-list mailing list