Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 243
comalex3 Avatar asked Aug 29 '15 11:08

comalex3


People also ask

What is purpose of parameter?

A parameter is a named variable passed into a function. Parameter variables are used to import arguments into functions. Note the difference between parameters and arguments: Function parameters are the names listed in the function's definition.

How do parameters work in functions?

A function parameter is a variable used in a function. Function parameters work almost identically to variables defined inside the function, but with one difference: they are always initialized with a value provided by the caller of the function.

How do parameters help?

Parameter variables help programs run specific functions with variable input. Giving unsuitable parameters will impact the working of the program – a calculation that is given a word instead of a number won't work!

What do parameters do in coding?

A parameter is a special kind of variable in computer programming language that is used to pass information between functions or procedures. The actual information passed is called an argument.


1 Answers

-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

like image 105
Bhargav Rao Avatar answered Oct 13 '22 17:10

Bhargav Rao