hit counter

Timeline

My development logbook

Get Rid of Self

I think this has been addressed in the responses; it’s not as easy as you’d think, and there are important advantages to the uniform interpretation of methods as “just functions that get called in a funky way”. In Ruby, everything is a method, or an anonymous block, and there are no “free functions”. Python uses the complimentary approach, treating functions as first-class citizens. Both approaches are complete; they are however incompatible, and you can’t easily morph one into the other. (Personally, I find that the criticm of explicit self has about as much merit as the criticism of Python’s use of whitespace.)”

http://www.artima.com/weblogs/viewpost.jsp?thread=214325

Why Do You Need Explicitly Have the ‘Self’ Argument Into a Python Method?

I like to quote Peters’ Zen of Python. “Explicit is better than implicit.”

I In Java and C++, this can be deduced, except when you have variable names that make it impossible to deduce. So you sometimes need it and sometimes don’t.

I Python elects to make things like this explicit rather than based on a rule.

I Additionally, since nothing is implied or assumed, parts of the implementation are exposed. self.__class__, self.__dict__ and other “internal” structures are available in an obvious way.

by S. Lott]