Why self?

Charles Hixson charleshixsn at earthlink.net
Tue Jul 9 13:51:07 EDT 2002


Lou Pecora wrote:
> ...
> You know, as much as I LOVE Python I got to agree this one bugs me,
> too.  I wish the scoping rules could be changed to default to self
>...

This is a mistake that I make frequently.  But it's one that's easy to 
fix.  The one that I really dislike is that there is no demarkated form 
of the language.  Indentation is good, and improves readability, but I 
always indent with tabs, and IDLE insists that tabs are 8 characters 
wide, where my standard is 3.  This is bad enough, but there are editors 
out there that will convert tabs to spaces, and vice versa, without 
warning you.  And there is one that even interprets tabs as being an 
absolute amount of spacing rather than a "space to the next tab mark". 
None of these warn you about what they are doing, so depending on tabs 
as a lexical identifier is ... fragile.  This has bitten me more than 
once, and is the primary reason why I find IDLE to be unuseable.

A lexical marker would solve this.  When I've though of doing an 
auto-convert script, however, I've always been stymied by one thing... 
Python already uses all of the punctuation that's readily typeable (the 
marker should only be one character wide).  A specialized editor could 
adapt curly quotes for this purpose, though it would look a bit wierd, 
but they don't seem to display well on Linux systems (i.e., many 
programs do things like rendering a close curly double-quote as either 
'' or &rdquot; , neither of which work well in a program context.

So I tend to accept the non-lexical divisions as a permanent design 
flaw, and accept it as a reasonable trade for the good features.  But 
this doesn't make me like it.

In contrast, the self argument actually makes sense as a distinction 
between locally bound routine names and class methods (not that I've yet 
had a use for locally bound routine names, but ...).
-- 
-- Charles Hixson
Gnu software that is free,
The best is yet to be.




More information about the Python-list mailing list