[issue5998] Add __bool__ to threading.Event and multiprocessing.Event
Florian Berger fber...@florian-berger.de added the comment: Voting for re-opening. I am currently porting a non-threaded function for use within a threaded application. If threading.Event had __bool__, it would be a drop-in replacement for simple True/False flags that can not be used in multithreaded code. To me, it is actually surprising that I can not do tests like if event: IMHO, if event.is_set(): ... is unnecessarily complicated, especially with the documentation speaking of a true/false flag all the time. I will subclass threading.Event now and add __bool__, but I don't feel this is a nice solution. -- nosy: +fberger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5998] Add __bool__ to threading.Event and multiprocessing.Event
Benjamin Peterson benja...@python.org added the comment: I'm closing because a lack of positive feedback on the list. -- nosy: +benjamin.peterson resolution: - rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5998] Add __bool__ to threading.Event and multiprocessing.Event
New submission from Floris Bruynooghe floris.bruynoo...@gmail.com: I think it would allow for more pythonic code if the threading.Event and multiprocessing.Event classes had the __bool__ special attribute. This would allow doing if e: ... instead of if e.is_set(): This could be backported to 2.x really easily by just replacing __bool__ to __nonzero__. See also the thread starting here: http://mail.python.org/pipermail/python-ideas/2009-May/004617.html -- components: Library (Lib) files: event.diff keywords: patch messages: 87587 nosy: flub severity: normal status: open title: Add __bool__ to threading.Event and multiprocessing.Event type: feature request versions: Python 2.7, Python 3.2 Added file: http://bugs.python.org/file13959/event.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5998 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com