What is -m
stands for in python -m unittest
? The unittest unit testing framework has other command line options like -v -b -c -t
but wondering what does -m
stands for? Is it part of unittest or other python command line option?

- 63
- 7
-
1see on your own `python --help` – Avinash Raj Jan 28 '18 at 03:36
-
2Possible duplicate of [Running a python package](https://stackoverflow.com/questions/6630822/running-a-python-package) – Stephen Rauch Jan 28 '18 at 03:37
-
`-m mod : run library module as a script (terminates option list)` - from help – Ganesh Kathiresan Jan 28 '18 at 03:37
1 Answers
if you run python --help
you will see that:
-m mod : run library module as a script (terminates option list)
An explanation as to what that means and -m
flage does can be found here, I have copied the important parts below:
Properly designed modules usually do nothing except set up stuff (e.g. functions and types you could import), but they usually won’t have any visible side effect. That’s why you can do import sys and nothing happens.
However, some modules may offer useful stuff when they are run from the command line. Examples for that include venv but also http.server or idlelib: All of those are regular modules that can be imported from other modules without side effects.
But when executed directly, they all do things (e.g. venv sets up a virtual environment, http.server runs a simple HTTP server, and idlelib runs IDLE). This is usually done with the following check:

- 878
- 8
- 16