the annoying, verbose self

George Sakkis george.sakkis at
Sat Nov 24 02:23:55 CET 2007

On Nov 23, 7:21 pm, "BJörn Lindqvist" <bjou... at> wrote:

> On Nov 23, 2007 11:54 PM, Steven D'Aprano
> > The correct solution to your example is to get rid of the attribute
> > lookups from the expression completely:
> No it is not. The "solution" is nothing more than a silly band-aid
> thrown out by people who cannot comprehend that Python may not be
> perfect in every little detail.

It sure isn't, but what would the best alternative be in this case?
Ruby's "@"? That's only one character less than "s." if "self." is too
long (as a compromise I sometimes use "my."). Also, static languages
can get away with implicit self (or "this") because (1) all attributes
are statically defined in the class body and (2) local variables must
be declared before used; neither of these is true for Python. I
certainly wouldn't consider better a solution that required declaring
local variables (e.g. "local x = 0").


More information about the Python-list mailing list