How am I misusing gflags in this example? Setting the flag on the command line doesn't override the default value, but when I set the flag as required and don't use a default value (the commented code), it gets set (to False
) just fine.
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