Code 85
Published in

Code 85

How To Pass Command-Line Values to a Python Script

Use argparse to define script values

Photo by Cupcake Media on Unsplash

Python provides a native library for passing command-line values to scripts called argparse. With argparse, we can include variable values in the execution command instead of using input() to request the value mid-execution. This saves us time and more importantly allows script execution lines to be saved and…




Plain language programming tutorials for non-developers

Recommended from Medium

My Development Team Infrastructure

I Code But I’m Not An Engineer

My very old 13 inch Macbook 2009 on the right bought by my older sister and 13 inch MacBook Air 2015 bought by my mom

What is JWT?

Announce Your Actions: Making gesture actions accessible

Minecraft Capes Mod 1.16.4/1.15.2 — The Player’s skin

Opt In or Opt Out Teams Call Queue Agents Remotely

Microsoft Teams Client Calls Settings

Writing CTFd plugins: a beginner walkthrough

JACS: NSAP Structure

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jonathan Hsu

Jonathan Hsu

Top writer with 2.5M+ views.

More from Medium

How to Fix UnicodeEncodeError: 'ascii' codec can't encode character in Python and Pandas

5 Best Ways to Get the Most Out of Pandas read_csv

Become A Expert in Python Comprehension

Some tips for using fixtures in pytest