use of "self", was "No Do while/repeat until looping construct in python?"
thomas at xs4all.net
Sat Mar 15 18:03:28 CET 2003
On Sat, Mar 15, 2003 at 08:44:38AM -0500, John Roth wrote:
> Ruby, for example, requires a "funny character" to distinguish
> instance variables and module/global variables from local variables.
> It borrowed the concept from Perl, although for a very different use.
Well, that depends on how you look at it. In Perl, '@', '%' and '$' (and
subs and FILEHANDLES and such, which have no prefix character) all live in
separate namespaces (and sometimes with subtly different rules governing
them, too.) @spam, %spam and $spam (can, and usually do) all point to
different objects, in different namespaces. So if you forget that the
namespaces are also type-specific, you can think of '@spam' as saying "get
me 'spam' from the 'array' namespace". If you do think of it like that, the
'glob' identifier ('*spam') also makes more sense; the * matches any
Thomas Wouters <thomas at xs4all.net>
Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
More information about the Python-list