Usage of main()
manuel.graune at koeln.de
Fri Sep 4 09:17:31 CEST 2009
Sean DiZazzo <half.italian at gmail.com> writes:
> I'm trying to come up with an answer for you, but I can't...
> The if __name__ == "__main__": idiom *is* the standard way to write
> python programs, but it's not there to speed up programs. It's there
> so that your program can be executed differently whether it is called
> as a runnable script from the command line, or if it is imported.
thanks for your answer. What you are explaining is exactly why I tried
it in the first place. I'm just wondering why (this is my impression,
not necessaryly the reallity) none of the recommended texts on python
put this in the first chapters. Instead - if it is mentioned at all -
it is hidden somewhere in the "advanced" sections. Even if the reason
for this is (I'm guessing...) because it is thought to be to complicated
to explain the "why" right at the beginning, it probably would not hurt
to just tell that this is the "correct" way of doing things right at the
start and add a footnote.
A hundred men did the rational thing. The sum of those rational choices was
called panic. Neal Stephenson -- System of the world
Key fingerprint = 1E44 9CBD DEE4 9E07 5E0A 5828 5476 7E92 2DB4 3C99
More information about the Python-list