Created
May 24, 2019 02:42
-
-
Save saber-zero/62fb1403a1752bb8d190aa25362cc91b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def str2bool(v): | |
if v.lower() in ('yes', 'true', 't', 'y', '1'): | |
return True | |
elif v.lower() in ('no', 'false', 'f', 'n', '0'): | |
return False | |
else: | |
raise argparse.ArgumentTypeError('Boolean value expected.') | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--True_or_False", type=str2bool, nargs='?', | |
const=True, default=True, | |
help="Activate nice mode.") | |
opt = parser.parse_args() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment