The __name__ == '__main__' hack (was: Double underscores -- ugly?)

Ben Finney bignose+hates-spam at benfinney.id.au
Mon Feb 18 19:33:26 EST 2008


benhoyt <benhoyt at gmail.com> writes:

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

Unlike the double-underscore attribute names for signalling "special
meaning", that particular hack is IMO unnecessarily ugly.

I don't, however, think it's likely to go away any time soon. If
that's the ugliest convention people can find in Python (as opposed to
the limitless *non*-conventional ugliness that programmers are capable
of in any language), then Python is doing pretty well.

-- 
 \       “An idea isn't responsible for the people who believe in it.” |
  `\                                      —Donald Robert Perry Marquis |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list