On Wed, May 8, 2013 at 4:10 AM, Jim Mooney <[email protected]> wrote: > > def main(): > pass > > if __name__ == '__main__': > main() > > What is that stuff? I thought I was getting away from all this > business of defining a main entry point. I don't see it in any of the > Py library files or other Py programs.
http://docs.python.org/3/library/__main__ For Windows multiprocessing see the "Safe import of main module" section: http://docs.python.org/3/library/multiprocessing#windows As to the standard library, excluding obvious test modules, I count approximately 150 uses in 3.3.1. http://pastebin.com/t78Aab8N http://hg.python.org/cpython/file/d9893d13c628/Lib In a couple of cases where the file is named __main__.py, the following test is used instead: if sys.argv[0].endswith("__main__.py"): Much of what I left in the list are entry points for tests and demos, but there are scripts too, such as pydoc, profile, tabnanny, and the new venv module for creating virtual environments. You can run a module as __main__ with the -m option. For example: python3 -m turtledemo.clock # POSIX py -3 -m turtledemo.clock # Windows w/ pylauncher _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor
