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.
Change History (14)
comment:1 Changed 18 months ago by wsanchez
- Summary changed from FlagsConstant objects should be iterable to FlagConstant objects should be iterable
comment:10 follow-up: ↓ 12 Changed 17 months ago by therve
- Keywords review removed
- Owner set to wsanchez
comment:11 Changed 17 months ago by wsanchez
- Resolution set to fixed
- Status changed from new to closed