1. Command line and environment — Python 2.7.18 documentation

Search sys.path for the named module and execute its contents as
the __main__ module.

Since the argument is a module name, you must not give a file extension
(.py). The module-name should be a valid Python module name, but
the implementation may not always enforce this (e.g. it may allow you to
use a name that includes a hyphen).

Package names are also permitted. When a package name is supplied instead
of a normal module, the interpreter will execute <pkg>.__main__ as
the main module. This behaviour is deliberately similar to the handling
of directories and zipfiles that are passed to the interpreter as the
script argument.

Note

This option cannot be used with built-in modules and extension modules
written in C, since they do not have Python module files. However, it
can still be used for precompiled modules, even if the original source
file is not available.

If this option is given, the first element of sys.argv will be the
full path to the module file. As with the -c option, the current
directory will be added to the start of sys.path.

Many standard library modules contain code that is invoked on their execution
as a script. An example is the timeit module:

python -mtimeit -s

'setup here'

'benchmarked code here'

python -mtimeit -h

# for details

See also

runpy.run_module()

Equivalent functionality directly available to Python code

PEP 338 – Executing modules as scripts

New in version 2.4.

Changed in version 2.5: The named module can now be located inside a package.

Changed in version 2.7: Supply the package name to run a __main__ submodule.
sys.argv[0] is now set to "-m" while searching for the module
(it was previously incorrectly set to "-c")