Rodrigo 🐍🚀
Rodrigo 🐍🚀

@mathsppblog

5 تغريدة Mar 18, 2023
The Python 🐍 command has many different switches.
Here are the 4 switches I use the most:
The switch `-c` runs code directly from the command line.
It doesn't open the REPL, and it is convenient for short, one-off expressions.
The result isn't printed by default, so don't forget your `print`!
The switch `-m` runs a module as a script.
This will run an installed module's section that is inside `if __name__ == "__main__":`.
The one I use the most is the module `timeit` to measure execution time.
The switch `-i` stands for Interactive.
By running your code with `-i`, after the script is done, you get a REPL session with the variables and functions from that script.
Useful to play around with functions you just defined.
The switch `-q` opens the REPL Quietly.
What this means is that it opens the REPL without displaying all the version/platform information.
I use it when recording videos and demoing stuff (thanks @learn_byexample!)

جاري تحميل الاقتراحات...