Thoughts about Python

Duncan Booth me at privacy.net
Tue Feb 24 10:36:10 EST 2004


Matthias <no at spam.pls> wrote in
news:36wu11g8ums.fsf at goya03.ti.uni-mannheim.de: 

>> The advantage of min and max as builtins are that they work on any 
>> sequence. In particular they work on iterators. Having functions that
>> apply to an arbitrary sequence avoids a lot of potential code
>> duplication. 
> 
> Do you mean code duplication on the user side?  Or code duplication in
> Python's implementations?  In the latter case, it seems strange to
> force inconsistent method/function usage on thousands of developers
> just in order to save a couple of lines in Python's source code.

I mean code duplication on the user side. A function that operates on every 
iterator or sequence type is far more useful than a protocol that more 
often than not wouldn't be implemented.

> 
> To me, Python's builtins are by far not a "problem", but I admit that
> I never understood why astring.len() doesn't work.
> 
Because it would have to begin and end with two underscores (thats the 
naming convention for special methods), and astring.__len__() already does 
what you want. But I think it is mostly for historical reasons.



More information about the Python-list mailing list