4 ms·
the thing is, self being explicit makes it more consistent unlike 'self' in other languages as a keyword, 'self' is just a variable with the same scoping. i.e
by tef__ 16y ago
the thing is, self being explicit makes it more consistent
unlike 'self' in other languages as a keyword, 'self' is just a variable with the same scoping.
i.e self always refers to the most inner scope in other languages (a special variable), meanwhile self in python is
wherever self was bound in the current scope.
and fwiw: len is a holdover from earlier python (you can define a method __len__ if you want...)
- artsrc 16y agoOnce you make a parameter special, subsequent effort to hide that it is special seems odd. The self parameter looked different in the call to the function.
- masklinn 16y ago> len is a holdover from earlier python No. len is basically a multimethod. > (you can define a method __len__ if you want…) You have to, it's part of the length protocol, `len()` will not work if you don't. Because `len(o)` calls `o.__len__()`). If you start calling underscore-methods directly (outside of a super() access), you're heading for trouble with your coworkers.