====== argparse ======
임의의 타입 parsing 하기
예) bool
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.add_argument("--nice", type=str2bool, nargs='?',
const=True, default=NICE,
help="Activate nice mode.")
...
script --nice
script --nice
bool 타입
command --feature / command --no-feature 방식
parser.add_argument('--feature', dest='feature', action='store_true')
parser.add_argument('--no-feature', dest='feature', action='store_false')
parser.set_defaults(feature=True)
* https://stackoverflow.com/questions/15008758/parsing-boolean-values-with-argparse
===== GUI =====
* https://github.com/chriskiehl/Gooey
===== 대체모듈 ======
* https://pypi.org/project/python-decouple/
{{tag>config args argparse}}