self (was Re: No Do while/repeat until looping construct in python?)

Piet van Oostrum piet at
Sat Mar 15 00:35:03 CET 2003

>>>>> "William Sonna" <wsonna at> (WS) wrote:

WS> You've just contradicted yourself, (which is OK; it illustrates the
WS> problem). Why would a local variable need to be qualified to keep it
WS> separate from the local namespace? That's the *conceptual* problem with
WS> "self".

WS> The *practical* problem is that because common sense says the instance
WS> variables are local, and typing "self" is a pain, the user has a double
WS> disincentive to include it, resulting in gratuitous bugs.

The common sense is wrong. Instance variables are not local variables. You
have in general three kinds of variables in a method: module level
variables (global), local variables, and instance variables. There must be
some way to distinguish them. If instance variables are not prefixed by
self, then they must be declared as such or the local variables must be
declared to be local. Smalltalk chose to do the latter; I have no idea what
Ruby does, but I guess it will do something similar.
Piet van Oostrum <piet at>
Private email: P.van.Oostrum at

More information about the Python-list mailing list