News for hackers. Stuff that matters.
Re:Ruby is beautiful (but I'm moving to Python) by tef__ on Sunday November 28, 2010 @01:45PM (#1947877)
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...)

Re:Ruby is beautiful (but I'm moving to Python) by masklinn on Sunday November 28, 2010 @02:53PM (#1948099)
> 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.

Re:Ruby is beautiful (but I'm moving to Python) by artsrc on Sunday November 28, 2010 @07:52PM (#1948919)
Once 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.