Note on PEP 299

B

bearophileHUGS

I don't like much the syntax of:
if __name__ == '__main__':

Some time ago I have read this PEP:
http://www.python.org/dev/peps/pep-0299/

And why it was refused:
http://mail.python.org/pipermail/python-dev/2006-March/062955.html

I think the name of the standard main function may be just main(), so
there isn't the problem with the import (and *maybe* the problem with
multiple Python versions can be ignored with Python 3.0).

If a module contains the main(), the main() is executed when the module
is run alone. Otherwise you can import the module, with the main()
function managed as a normal function.

Bye,
bearophile
 
T

Terry Reedy

I don't like much the syntax of:
if __name__ == '__main__':

Some time ago I have read this PEP:
http://www.python.org/dev/peps/pep-0299/

And why it was refused:
http://mail.python.org/pipermail/python-dev/2006-March/062955.html

I think the name of the standard main function may be just main(), so
there isn't the problem with the import (and *maybe* the problem with
multiple Python versions can be ignored with Python 3.0).

This idea, and a couple of variations, have come up in the Py3 discussions,
so something might be tried.

tjr
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top