| Humor me for a moment, because I've been asking this question of many people for a long time and have never yet gotten a straight answer. Why is len() always the thing people pick on? Why is it always "Python uses len(obj) instead of obj.len()", and never "Python uses str(obj) instead of obj.str()", or any of the various polymorphic built-ins like sum()? I've seen this so many times now that I'm honestly quite curious about it. Also: "More consistent commitment to object paradigm, e.g. all function calls are actually method calls on an object." Every function call in Python is always an invocation of a method on an object, even if it doesn't look like it. len(), of course, delegates to a method on the object. But even standalone functions are method calls. Try this: >>> def add(x, y): ... return x + y ... >>> add(3, 5) 8 >>> import types >>> types.FunctionType.__call__(add, 3, 5) 8 The last couple lines there are what's really going on when you call the function. (also, just as Ruby's "built-in" functions are really methods on Kernel which is made available globally, Python's "built-in" functions really exist in a module that's made available globally (and __builtins__ is its name) |
Of course, even if str was a function and not a constructor, it would be an object factory which delegates to its argument via a well defined interface (the __str__ method). OOP doesn't have to mean everything-is-an-object.