I always found it weird that they use len([1,2,3]) rather than [1,2,3].len
(no, I don't want to call [0,1,3].__len__() . Why would I want to add all of those underscores.)
(no, I don't want to call [0,1,3].__len__() . Why would I want to add all of those underscores.)
Because they don't depend on a given class, they're protocols. There's no "master class" in which to put them, so they go in some sort of bastardized CLOS-like generic method instead.
''.join([1, 2, 3])By the way, your example has an error, since you can't join a list of numbers. You can only join lists of strings. I.e.
' '.join("Hello", "World")string.join(['1','2','3'], ' ') == ' '.join(['1','2','3'])