Double underscores -- ugly?

Terry Reedy tjreedy at udel.edu
Tue Feb 19 03:23:29 CET 2008


"benhoyt" <benhoyt at gmail.com> wrote in message 
news:a52fa343-1b7a-4e99-8841-6b64a046ca1a at i7g2000prf.googlegroups.com...
| Hi guys,
|
| I've been using Python for some time now, and am very impressed with
| its lack of red tape and its clean syntax -- both probably due to the
| BDFL's ability to know when to say "no".
|
| Most of the things that "got me" initially have been addressed in
| recent versions of Python, or are being addressed in Python 3000. But
| it looks like the double underscores are staying as is. This is
| probably a good thing unless there are better alternatives, but ...
|
| Is it just me that thinks "__init__" is rather ugly?

No, the reservered special names are supposed to be ugly ;-) -- or at least 
to stand out.  However, since special methods are almost always called 
indirectly by syntax and not directly, only the class writer or reader, but 
not users, generally see them.

| Not to mention  "if __name__ == '__main__': ..."?

Someone (perhaps me) once suggested on pydev using 'main' instead, but a 
couple of people piped back that they regularly name their main module (as 
opposed to the startup script) 'main'.  So much for that idea.  'main__' 
might not look as bad, but anything other that '__main__' introduces an 
inconsistency with the reserved name rule.  Changing '__name__' has the 
same pair of problems (conflict with user names and consistency).  So I 
decided to live with the current incantation.

Terry Jan Reedy



| 






More information about the Python-list mailing list