Daily Dose of Data Science

Share this post

9 Command Line Flags To Run Python Scripts More Flexibly

www.blog.dailydoseofds.com

9 Command Line Flags To Run Python Scripts More Flexibly

Commonly used Python command-line options.

Avi Chawla
Apr 21, 2023
11
Share
Share this post

9 Command Line Flags To Run Python Scripts More Flexibly

www.blog.dailydoseofds.com

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 :)

Thanks for reading Daily Dose of Data Science! Subscribe for free to learn something new and insightful about Python and Data Science every day. Also, get a Free Data Science PDF (250+ pages) with 200+ tips.

πŸ‘‰ 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!

Share Daily Dose of Data Science


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.

11
Share
Share this post

9 Command Line Flags To Run Python Scripts More Flexibly

www.blog.dailydoseofds.com
Previous
Next
Comments
Top
New
Community

No posts

Ready for more?

Β© 2023 Avi Chawla
Privacy βˆ™ Terms βˆ™ Collection notice
Start WritingGet the app
SubstackΒ is the home for great writing