This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: -m is not universally applicable
Type: enhancement Stage:
Components: Versions: Python 3.4
Status: closed Resolution: duplicate
Dependencies: Superseder: Add an option to pdb/trace/profile to run library module as a script
View: 9325
Assigned To: Nosy List: Claudiu.Popa, Devin Jeanpierre, berker.peksag, ncoghlan, r.david.murray, tshepang
Priority: normal Keywords:

Created on 2013-03-19 00:14 by Devin Jeanpierre, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg184564 - (view) Author: Devin Jeanpierre (Devin Jeanpierre) * Date: 2013-03-19 00:14
Many executables in python are meant to be run on python scripts, but can't run python scripts that are part of a package. For example, one can do `python -m pdb`, but not `python -m pdb`. This makes it more difficult to interact with executable scripts within a package. In particular, the following will NOT work in general: `python -m pdb package/`

It would be easier if these modules gained their own `-m` argument to specify import paths instead of files. For example, the third party coverage module does this, and can be run using the command `python -m coverage run -m`.

What follows is a small list of scripts present as modules in the Python stdlib that involve manipulating other scripts, and so could benefit from a -m option.


In the case of pydoc, unittest (unittest discover, etc.) -- these are special cases, as they interpret input as either a path OR a module via guessing. There may not be any benefit to adding a -m option.
msg184591 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-03-19 04:29
I think this is a reasonble idea, however there is no intrinsic relationship between these modules, so adding -m to each one should be a separate issue.  We can use this issue as a master and make the other issues dependencies of this one.

As a new feature any such changes would go into 3.4 at this time.
msg198452 - (view) Author: Nick Coghlan (ncoghlan) * (Python committer) Date: 2013-09-26 22:33
runpy needs to be refactored at least a bit before this will be practical. Issue 9325 is an existing issue for the same idea that discusses some of the problems to be resolved (it's a good idea, just a fair bit of work).
Date User Action Args
2022-04-11 14:57:43adminsetgithub: 61675
2013-09-26 22:33:17ncoghlansetstatus: open -> closed
superseder: Add an option to pdb/trace/profile to run library module as a script
resolution: duplicate
messages: + msg198452
2013-09-26 21:25:28pitrousetnosy: + ncoghlan
2013-09-26 19:25:44Claudiu.Popasetnosy: + Claudiu.Popa
2013-09-26 18:48:54berker.peksagsetnosy: + berker.peksag
2013-03-22 19:04:25tshepangsetnosy: + tshepang
2013-03-19 04:29:05r.david.murraysetnosy: + r.david.murray

messages: + msg184591
versions: + Python 3.4, - Python 3.3
2013-03-19 00:14:07Devin Jeanpierrecreate