2 ms·
Python takes a different tactic, and has a non-object-oriented len() method What do you mean? In Python len() is just a standard protocol for getting th
by bad_user 15y ago
Python takes a different tactic, and has a
non-object-oriented len() method
What do you mean?
In Python len() is just a standard protocol for getting the length of something, but len() itself is calling obj.__len__() if it is defined. You can even override or replace it in an object instance, returning whatever you want.
You can argue that these protocols are a bad idea, or maybe a useless one since Ruby does just fine without such hardcoded conventions, but since it relies on runtime adhoc polymorphism, it is as object oriented as it gets.
- afiler 15y agoI meant it only in the superficial sense, that the call of len() is called as len(foo), not foo.len(). I guess this is another example of why using the term "object-oriented" at all can be unhelpful, as it may mean so many different things to different people depending on the particular situation.