On 01/12/2010 17:08, m b wrote:


 > >
 > > if __name__ == "__main__":
 > > main()

What does this mean?

/Mikael

Python will not cause the main() function to run automatically when you execute the script, it has to be called.

__name__ is a special variable which is set by the python interpreter when it runs a source file. If the source file is run directly(as opposed to being imported), then the value of __name__ will be set to __main__.

so

if __name__ == "__main__":
  main()

checks to see if the source file be being directly executed, and if it is, calls the main() function.


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to