Proposal for removing self

Alex Martelli aleaxit at
Fri Aug 27 19:37:43 CEST 2004

Dave Benjamin <ramen at> wrote:
> > While it's also a good idea in Java, it's not as compelling as in C++,
> > because Java mostly lacks the complications due to C++'s templates and
> > freestanding ("not inside a class") names (haven't looked at Java
> > generics so I don't know if they got those complications back in;-).
> Java's generics aren't nearly as liberal as C++ templates. They're basically
> just syntax sugar for casting, so I doubt this would change much. I still
> prefer the explicit "this." or "self.", mainly because it is a pattern that
> I can use consistently across all of the languages I regularly program in
> (JavaScript and ActionScript, like Python, make "this" mandatory as well).

Hmmm, yes, you have a point _in a multilanguage perspective_.
Unfortunately most programmers appear to dislike the concept of being
fluent across several languages.

> That said, if an existing C++ or Java code base uses prefixes for all
> instance variables, it's a bit redundant to add "this.". I have this
> situation at my work, where I reluctantly have to make an exception to avoid
> pissing people off. ;)

Prefix naming is the norm, but I fail to see why 'member_foo' or
'my_foo' should be considered better than ''.  Sure, if you work
with an existing body of code it's generally better to follow its
conventions, otherwise your modifications stand out like a sore thumb.


More information about the Python-list mailing list