3 ms·
Because len() is a global function. That's perfectly fine in an OO system (everything does not have to be an object, attribute or method). Sure, it's not as con
by w8rbt 11y ago
Because len() is a global function. That's perfectly fine in an OO system (everything does not have to be an object, attribute or method). Sure, it's not as consistent as anything.len(), but it works just fine. That's often the reason why Ruby claims to be a cleaner OO implementation than Python.
To me, Python really shows its warts when reversing a string. Something you never do out side of school (or on big ending to little endinan conversions).
In Python 2:
string[::-1]
In Ruby:
string.reverse()
Now that's mind boggling and totally yucky.