- Daily Dose of Data Science
- Posts
- 9 Command Line Flags To Run Python Scripts More Flexibly
9 Command Line Flags To Run Python Scripts More Flexibly
Commonly used Python command-line options.

When invoking a Python script, you can specify various options/flags. They are used to modify the behavior of the Python interpreter when it runs a script or module.
Here are 9 of the most commonly used options:
π· π©π²ππ‘π¨π§ -π: Run a single Python command. Useful for running simple one-liners or testing code snippets.
π· π©π²ππ‘π¨π§ -π’: Run the script as usual and enter the interactive mode instead of terminating the program. Useful for debugging as you can interact with objects created during the program.
π· π©π²ππ‘π¨π§ -π: Ignore assert statements (This is alphabet βOβ). Useful for optimizing code by removing debugging code.
π· π©π²ππ‘π¨π§ -ππ: Ignore assert statements and discard docstrings. Useful for further optimizing code by removing documentation strings.
π· π©π²ππ‘π¨π§ -π: Ignore all warnings. Useful for turning off warnings temporarily and focusing on development.
π· π©π²ππ‘π¨π§ -π¦: Run a module as a script.
π· π©π²ππ‘π¨π§ -π―: Enter verbose mode. Useful for printing extra information during program execution.
π· π©π²ππ‘π¨π§ -π±: Skip the first line. Useful for removing shebang lines or other comments at the start of a script.
π· π©π²ππ‘π¨π§ -π: ignore all Python environment variables. Useful for ensuring a consistent program behavior by ignoring environment variables that may affect program execution.
Which ones have I missed? Let me know :)
π Read what others are saying about this post on LinkedIn.
π If you liked this post, donβt forget to leave a like β€οΈ. It helps more people discover this newsletter on Substack and tells me that you appreciate reading these daily insights. The button is located towards the bottom of this email.
π If you love reading this newsletter, feel free to share it with friends!
Find the code for my tips here: GitHub.
Reply