Nick Coghlan <ncogh...@gmail.com> added the comment:

I've thought about this in the past, but never really pursued it due to the 
question of what to do with the __main__ namespace.

There are three options here:
1. Use runpy.run_module to run the module in a fresh __main__ namespace
2. Use runpy.run_module to run the module under its own name
3. Use runpy._run_module_as_main to run the module in the real __main__ 
namespace

Option 3 is probably a bad idea (due to the risk of clobbering globals from 
pdb/trace/profile/doctest/etc) but failing to do it that way creates a 
difference between the way the actual -m switch works and what these modules 
will be doing.

That said, I haven't looked closely at what these modules do for ordinary 
scripts, where much the same problem will already arise. If option 1 is 
adequate for this purpose, then it shouldn't be that hard to add - it's just 
that I've never done the investigation to see if it *would* be adequate.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue9325>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to