Skip to content

Instantly share code, notes, and snippets.

@cngkaygusuz
Created August 21, 2014 14:52
Show Gist options
  • Save cngkaygusuz/5405e694afd95357a29f to your computer and use it in GitHub Desktop.
Save cngkaygusuz/5405e694afd95357a29f to your computer and use it in GitHub Desktop.
Get arguments from command line using built-in argparse library and receive them in a dictionary.
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--argument_one", help="This argument does nothing")
parser.add_argument("--argument_two", help="This argument is even more useless than other one.")
parsed = parser.parse_args() # By default, this uses sys.argv.
# This means the arguments doesnt have to be coming from CLI.
print parsed.__dict__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment