Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
GoogleCodeExporter opened this issue Jul 20, 2015 · 1 comment
Open

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 [email protected] 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 [email protected] on 20 Apr 2012 at 1:32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant