Fixing Python's String class
pydanny.com
pydanny.com
This is 2013, strings are Unicode now, and we have to stop thinking of them as arrays of characters. The most widely used Unicode encodings, UTF-8 and UTF-16, both have variable-length characters.
http://stackoverflow.com/questions/83983/why-isnt-the-len-fu...
To answer the first question, Python allows you to ask about the size of any finite collection, including collections for which knowing the actual length could require an O(n) (or greater!) traversal, and collections which are mutable and can have lengths which change. A method is a far better fit than an attribute for describing the length, since it is something that might have to be calculated rather than being known a priori.
(Of course, nearly all collections keep accounting of their length at all times, but the reasoning is still there.)
The second reason, about len() being external to collections, is related to Python's heritage. I posit, without proof, that len() is external because Python's granddaddy is Smalltalk, where iteration and collection manipulation are external, inverted from what we would expect in other modern languages.
Now, with all of this said, the actual reasons are lost to history, and I don't know if anybody actually knows the exact reason for the design decision anymore. But, nonetheless, that's the way that it is. Hope this was interesting.
Edit: Well, never mind, looks like Guido did explain it. Today I learned things. Leaving this up for posterity, but please do ignore it.