Skip to content
This repository has been archived by the owner on Dec 29, 2022. It is now read-only.

Should DEFINE_boolean() allow "None" as the default value? #10

Closed
GoogleCodeExporter opened this issue Mar 14, 2015 · 2 comments
Closed

Comments

@GoogleCodeExporter
Copy link

Currently, we can define a boolean flag with default value to None:

 FLAGS = gflags.FLAGS
 gflags.DEFINE_boolean("the_flag", None, "The flag.")

I'm not sure if this is expected or should it be allowed, since python-gflags 
project tries to mimic the C++ version of gflags as close as possible.  This is 
troublesome because user may be unaware that a boolean flag can fail both of 
the following assertions:

 assertTrue(FLAGS.the_flag)  # AssertionError: None is not True
 assertFalse(FLAGS.the_flag)  # AssertionError: None is not False

Original issue reported on code.google.com by linshu...@chromium.org on 4 Apr 2012 at 8:04

@GoogleCodeExporter
Copy link
Author

Sorry for the late reply -- I'm not really the right person to speak to this 
for several reasons.  Besides not being the project maintainer anymore, I also 
don't know what the best thing to do is.  I agree it makes sense that a flag of 
type boolean should have type bool(), which None doesn't, but I don't know if 
it's reasonable to change the API at this point.

Original comment by csilv...@gmail.com on 20 Apr 2012 at 1:32

@gpshead
Copy link
Contributor

gpshead commented Sep 28, 2017

python-gflags users should migrate to absl-py:
https://github.com/abseil/abseil-py
https://pypi.python.org/pypi/absl-py/

It is the modern version of this library.

@gpshead gpshead closed this as completed Sep 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants