Quote:
Original post by Kylotan
Python doesn't tend to have inheritance hierarchies like that, so I'm not sure how relevant that is.
I used to know the reasonably-good reason why len isn't a member, but I can't find it. Maybe it's to do with encouraging the functional paradigm. Maybe it's because you're expected to be able to call it on objects that have no concept of length and get a reasonable exception back, rather than a 'no such method' exception.
Well, seeing as how Python now discourages the usage of filter() and appl() in favor of list comprehension, I don't think that this is the reason. So the functional paradigm is out.
As for the reasonable exception, I don't think that's it. Basically, I'd say that since Python did not originally start out object-oriented (Ruby did), they made len() a generic function. I'd say this is the reason. But it's still weird that they changed strings from:
import stringstring.replace("hello", "h", "j") # hello -> jello
to :
"hello".replace("h", "j")
I mean, if you're going to change that, might as well be consistant and change the whole thing. Anyway, that's what of my irks with Python, but on the whole, I really like the language.