[Python-ideas] PEP for executing a module in a package containing relative imports

Ron Adam rrr at ronadam.com
Mon Apr 23 01:50:17 CEST 2007


Jim Jewett wrote:

> As long as we're in python-ideas, I'll throw out the radical
> suggestion of auto-importing sys into builtins, the way os autoimports
> path.

+1

I thought that this was discussed before and had gotten general approval.



Also it makes sense to me to have additional entries in sys to identify the 
starting main, and the root package modules.  I also like the idea of 
having a way to say this_module.

if __module__ is sys.__main__:
    ...

Notice names aren't used this way, which is generally how you would compare 
any object in python.  You wouldn't try to get it's name and then compare 
that to the name of another object.

Ron



More information about the Python-ideas mailing list