Created
March 28, 2021 13:39
-
-
Save MalteGruber/f320dfae4ef447d88ce7d4dc940da6d4 to your computer and use it in GitHub Desktop.
Python Argparse flag without argument
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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