On Wed, Jan 5, 2011 at 11:48 AM, Ron Adam firstname.lastname@example.org wrote:
(This is probably something that was suggested more than a few times before.)
Would it help if global name space acquired a __main__ name? Then the standard if line becomes only a slightly different "if __name__ == __main__: main()". I think that would make more sense to beginners also and it is a bit less magical.
For now, both ways could work, __main__ would be "__main__" or None, but down the road, (long enough to be sure everyone knows to drop the quotes), both __main__ and __name__ could be switched to the actual module name so that __name__ and __module__ attributes would always be correct.
If we decided to actually change the way the main module was executed, the most likely result would be to resurrect PEP 299. Changing that particular idiom is probably a Py4k scale of change though :P
-- Nick Coghlan | email@example.com | Brisbane, Australia