[Tutor] object orientation
Gregor Lingl
glingl at aon.at
Mon Nov 15 08:44:18 CET 2004
Alan Gauld schrieb:
>>to know why we write len(x) instead of x.len()
>>
>>
>
>There was a thread about this a fw weeks ago
>- either here or comp.lang.python.
>
>I think history is the real answer. When Guido first built Python
>not everything (strings, ints, floats etc) were first class
>objects so making len() a function meant it was more generally
>useful. Nowadays len() could just as well be an object method.
>
>
And, in fact, behind the scene it is:
>>> "abc".__len__()
3
>>> [].__len__()
0
>>>
Regards,
Gregor
>Alan G.
>
>_______________________________________________
>Tutor maillist - Tutor at python.org
>http://mail.python.org/mailman/listinfo/tutor
>
>
>
>
More information about the Tutor
mailing list