Skip to content

Instantly share code, notes, and snippets.

@MalteGruber
Created March 28, 2021 13:39
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 MalteGruber/f320dfae4ef447d88ce7d4dc940da6d4 to your computer and use it in GitHub Desktop.
Save MalteGruber/f320dfae4ef447d88ce7d4dc940da6d4 to your computer and use it in GitHub Desktop.
Python Argparse flag without argument
import argparse
parser = argparse.ArgumentParser(description='My Program')
# Flag without arguments, False if not provided
parser.add_argument('--from-script','-s', dest='started_from_script',action='store_true', help='')
args = parser.parse_args()
print(args.started_from_script)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment