comalex3
comalex3

Reputation: 2606

What do -u, -m parameters do?

What do parameters -u, -m mean and what do they do?

for example:

python -u my_script.py 

or

python -m my_script.py

Where can I read about them?

Upvotes: 18

Views: 15694

Answers (1)

Bhargav Rao
Bhargav Rao

Reputation: 52081

-u is used to force stdin, stdout and stderr to be totally unbuffered, which otherwise is line buffered on the terminal

-m searches sys.path for the named module and runs the corresponding .py file as a script. An example would be timeit module. The command python -m timeit "python script" would return the time taken for the script to execute.

Quoting from the docs

-u

Force stdin, stdout and stderr to be totally unbuffered. On systems where it matters, also put stdin, stdout and stderr in binary mode.

-m <module-name>

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

You can read more about them and other options here

Upvotes: 29

Related Questions