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.
I like to explore, experiment and write about data science concepts and tools. You can read my articles on Medium. Also, you can connect with me on LinkedIn and Twitter.