Floris Bruynooghe wrote:
I was wondering why threading.Event hasn't got the __nonzero__ special attribute? I think it would allow for code to be more pythonic if you could just do "if e: ..." instead of "if e.isSet(): ..." (or "if e.is_set(): ..." in 2.6+).
2.6 and 3.1 are feature frozen.
I think the proposal should be to add __bool__ to 3.2 and maybe backport to 2.7 as __nonzero__. It is possible that 3.2 will get new features not added to 2.7, but I doubt the opposite.
The patch is trivial:
--- Lib/threading.py (revision 72551) +++ Lib/threading.py (working copy) @@ -371,6 +371,9 @@
is_set = isSet
- def __nonzero__(self):
- def set(self): self.__cond.acquire() try:
Is it worth submitting this to the tracker or is there some reason why this is a bad idea that I've missed?
Since you have a patch that people could grab and apply, and not just an idea, I say submit too.