Skip to content

Instantly share code, notes, and snippets.

@sdreher
Last active July 25, 2018 18:07
Show Gist options
  • Save sdreher/d79c91ebc4ab6d97bfcfb8a57c21e5e7 to your computer and use it in GitHub Desktop.
Save sdreher/d79c91ebc4ab6d97bfcfb8a57c21e5e7 to your computer and use it in GitHub Desktop.
import argparse
def main(args):
print(args.url)
def parse_arguments():
parser = argparse.ArgumentParser(description="Accept arguments")
parser.add_argument('-url', '--url', required=True)
return parser.parse_args()
if __name__ == '__main__':
args = parse_arguments()
main(args)
@sdreher
Copy link
Author

sdreher commented Jul 25, 2018

  1. Save as sample.py
  2. Run from the command line like so: python ./sample.py --url https://www.google.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment