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

Adam Atlas adam at atlas.st
Mon Apr 23 02:00:44 CEST 2007


On 22 Apr 2007, at 19.50, Ron Adam wrote:
> I also like the idea of
> having a way to say this_module.
>
> if __module__ is sys.__main__:
>     ...

Agreed... I suggested something like that a couple of days ago  
(except assuming __main__ would be a builtin global instead of in  
sys). I proposed __this__ as the name for accessing the current  
module. Mainly because I like the Englishlike way it reads: "if  
__this__ is __main__". 'If this is main' -- couldn't be simpler.

Though I'd also be fine with sys.__main__ or sys.main (I'd prefer the  
latter). I would support having sys be an automatic global.



More information about the Python-ideas mailing list