Ticket #6302 enhancement closed fixed
FlagConstant objects should be iterable
|Reported by:||wsanchez||Owned by:||wsanchez|
(diff, github, buildbot, log)
I have a method that takes a FlagConstant argument, and I want to iterate through the flags to (a) flip the switches the flags should flip and (b) make sure there's no flag being sent that I don't know how to support.
For example, the caller starts by composing a FlagConstant from others:
flags = QueryFlags.NOT | QueryFlags.caseInsensitive
This is passed to my method. What I'd like to make work is:
for flag in flags: ... # I get (QueryFlags.NOT, QueryFlags.caseInsensitive)
The best I can do for now, appears to be:
for flag in (flags._container.lookupByName(name) for name in flags.names): ...
Note that I had to use the private flags._container attribute above.