[Python-ideas] Module aliases and/or "real names"

Ron Adam rrr at ronadam.com
Wed Jan 5 05:18:16 CET 2011



On 01/04/2011 08:00 PM, Nick Coghlan wrote:
> On Wed, Jan 5, 2011 at 11:48 AM, Ron Adam<rrr at ronadam.com>  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

Well, changing it in the way PEP 299 suggests is probably even a Py5k 
change.  Which is why I didn't suggest that. ;-)

Also PEP 299 main motivation is different than what is being discussed here.

Cheers,
   Ron



More information about the Python-ideas mailing list