Incorret flags.DEFINE_boolean() behavior
AshiakerWang opened this issue · 3 comments
AshiakerWang commented
demo python script
from absl import app
from absl import flags
FLAGS = flags.FLAGS
flags.DEFINE_boolean('tea',True,'Soggy Leaves')
def test(unused_argv):
if FLAGS.tea:
print( "have some tea" )
else:
print( "no tea" )
if __name__ == '__main__':
app.run(test)
The following output is expected while executing python test2.py --tea False
in the command line
no tea
However, the actual output while executing python test2.py --tea False
is
have some tea
In other words, no matter which boolean argument(i.e. True or False) is set in the command line, the output of the demo python script remains unchanged.
AshiakerWang commented
gpshead commented
boolean flags do not take an additional argument. --tea
means True. --notea
means False. --tea=True
and --tea=False
and related true/false values after = also work.
AshiakerWang commented
Thanks for your explanation!