[Python-ideas] Fwd: New suggested built in keyword: do

Jamie Willis jw14896.2014 at my.bristol.ac.uk
Fri Jun 8 11:08:00 EDT 2018

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.dorp at 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 at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180608/38afcf1b/attachment.html>

More information about the Python-ideas mailing list