0
我在此示例中如何滥用gflags?在命令行上设置标志不会覆盖默认值,但是当我根据需要设置标志并且不使用默认值(注释代码)时,它会被设置(至False
)。未在python-gflags中设置标志
import gflags
from gflags import FLAGS
#gflags.DEFINE_bool('use_cache', None, '')
#gflags.MarkFlagAsRequired('use_cache')
gflags.DEFINE_bool('use_cache', True, '')
if __name__ == '__main__':
if FLAGS.use_cache == True:
print 'use_cache == True'
else:
print 'use_cache == False'
。
~ python testflags.py --use_cache=False
use_cache == True
~ python testflags.py --help
use_cache == True