Skip to content

Instantly share code, notes, and snippets.

@sadysnaat
Created April 23, 2016 10:39
Show Gist options
  • Save sadysnaat/831fa012248f68e6f8635c55641ad5d8 to your computer and use it in GitHub Desktop.
Save sadysnaat/831fa012248f68e6f8635c55641ad5d8 to your computer and use it in GitHub Desktop.
Use command line arguments in python script
import sys
# Read this
# https://docs.python.org/2/library/sys.html#sys.argv
# you can use
report = sys.argv[1]
# this way first argument that is passed
# to the script will be report location
# If you are further instersted you can use
# https://docs.python.org/dev/library/argparse.html
# argparse libary from python
# It allows you to have positional and optional arguments
# with ease for a gentle introduction please refer
# https://docs.python.org/dev/howto/argparse.html#id1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment