Skip to content

Instantly share code, notes, and snippets.

@danielpsf
Created August 24, 2018 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielpsf/43fb359ef63d607cb5f2e01fb7b1b51c to your computer and use it in GitHub Desktop.
Save danielpsf/43fb359ef63d607cb5f2e01fb7b1b51c to your computer and use it in GitHub Desktop.
Simple way of using multiple parameters in Python using argparse
import argparse
parser = argparse.ArgumentParser()
parser.add_argument(
'--potatoes', '-p',
nargs='*',
type=str,
required=True,
help='Type of potatoes that you like most'
)
args = parser.parse_args()
print('I think you said you like:')
for potato in args.potatoes:
print('- {}'.format(potato))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment