|
|
|
|
|
by cies
1946 days ago
|
|
I dont consider prototypes-based OO a real OO. I thought Python had classes in the first release but not to be used by library/application makers. But I was probably mistaken. Thanks for setting that straight. What I think is rather unidiomatic in OO langs is Pythons "function/methods" like `len(x)` which is implemented as `__length__()`. This is just weird/unintuitive/unidiomatic OO... I do not know what Guido was on when he thought this was a good idea. |
|
Fair enough - in some ways it’s like half-way to an OO system. Yes, it’s theoretically elegant to have everything be an object and not to have classes. However in the vast majority of cases it seems prototype-based OO is only used as a foundation upon which to build a class system.
> What I think is rather unidiomatic in OO langs is Pythons "function/methods" like `len(x)` which is implemented as `__length__()`.
AFAIK the reason for the double-underscore method for `len` is to avoid it accidentally working for, say, a Rectangle class that exposes `length` and `width`.