A Python 3000 Question

Duncan Booth duncan.booth at invalid.invalid
Wed Oct 31 15:45:59 CET 2007

Neil Cerutti <horpner at yahoo.com> wrote:

> On 2007-10-31, Duncan Booth <duncan.booth at invalid.invalid> wrote:
>> Obviously it isn't an absolute thing: lists and dictionaries do
>> have other methods in the user namespace, so the decision to
>> keep len out of that namespace is partly a judgement call, and
>> partly historical (I think tuples didn't used to have any
>> methods at all).
> Thanks for the interesting note. I didn't know that tuples
> originally had no methods. That made len mandatory, I suppose.
Only if you think tuples are a sequence rather than a record. :)

Come to think of it, strings didn't have methods either, so len needed to 
be a function to get the length of a string.

I'm not sure when tuples sprouted methods. Strings grew methods in 1.6, but 
I think numbers and tuples may not have got any methods until the 
introduction of new-style classes (Python 2.2)

More information about the Python-list mailing list