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

DuplicateFlagError when module with gflags definition is reimported #9

Open
GoogleCodeExporter opened this issue Jul 20, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

A DuplicateFlagError is thrown when:
1) Module A imports the gflags module and defines gflags.
2) Module A imports B
3) Module B imports A

Example:

File main.py:
---------------------------------
#!/usr/bin/python2.6

import sys
import gflags
import dep   # error

FLAGS = gflags.FLAGS
gflags.DEFINE_boolean("example", True, "example_flag")

if __name__ == "__main__":
  FLAGS(sys.argv)
  print FLAGS.example

---------------------------------


File dep.py:
---------------------------------
#!/usr/bin/python2.6

import main
---------------------------------


Error output:
---------------------------------
Traceback (most recent call last):
  File "example\main.py", line 10, in <module>
    gflags.DEFINE_boolean("example", True, "example_flag")
  File "C:\gflags\python\gflags.py", line 2378, in DEFINE_boolean
    DEFINE_flag(BooleanFlag(name, default, help, **args), flag_values)
  File "C:\gflags\python\gflags.py", line 2190, in DEFINE_flag
    fv[flag.name] = flag
  File "C:\gflags\python\gflags.py", line 1040, in __setitem__
    raise DuplicateFlagError(name, self)
gflags.DuplicateFlagError: The flag 'example' is defined twice. First from 
main, Second from example\main.py

Original issue reported on code.google.com by [email protected] on 26 Mar 2012 at 7:11

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