Meaning of python -m flag Meaning of python -m flag python python

Meaning of python -m flag


From Python Docs:

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.


If you type python --help

You get

// More flags above-m mod : run library module as a script (terminates option list)// and more flags below

A great many things in a terminal will show you how to use it if you either use command --help or man command


The -m stands for module-name.

From Command line and environment:

python [-bBdEhiIOqsSuvVWx?] [-c command | -m module-name | script | - ] [args]