What about just supporting filtering syntax at the top level? for x range(50) if x % 2: print(x)
It's a minor syntactic change which is very flexible and consistent with the existing comprehension syntax. Could even extend to allow multiple iterators as per a comprehension On Fri, 8 Jun 2018, 15:59 Jacco van Dorp, <j.van.d...@deonet.nl> wrote: > Given that an exhaust method for generators didn't make it, I dont > think a keyword has more chance. For reference, that exhaust method > would have looked like: > > (print (x) for x in range(50)).exhaust() > > and be defined as: > > def exhaust(self): > for _ in self: > pass > > Also, there was some more involved method that did it in less > characters, having to do with queues of length 0 or something. > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/