jdhao's digital space

Recent content on jdhao's digital space

马上订阅 jdhao's digital space RSS 更新: https://jdhao.github.io/index.xml

Set up the Default Value for Boolean Option in Argparse

2018年10月11日 16:33

TL;DR

If you want to set a parameter’s default value to True using argparse, use

parser.add_argument('--param', action='store_false')

Otherwise, use

parser.add_argument('--param', action='store_true')