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

There is one, it just isn't public: runpy._run_module_as_main.

It's a private API that the -m switch implementation calls, and was introduced 
after the original runpy.run_module was found not to offer everything the 
switch needed.

It isn't possible to fully emulate -m from Python code though, as the lifecycle 
of the real main module is intertwined with the lifecycle of the underlying 
interpreter.

So if folks really want to try to do this, the source code is there to look at, 
but we're not giving the false impression that it's easy to do correctly with 
no unintended consequences.

----------

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

Reply via email to