<div dir="ltr">How do you implement "async for"?<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Apr 26, 2015 at 11:21 PM, Mark Shannon <span dir="ltr"><<a href="mailto:mark@hotpy.org" target="_blank">mark@hotpy.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I was looking at PEP 492 and it seems to me that no new syntax is required.<br>
<br>
Looking at the code, it does four things; all of which, or a functional equivalent, could be done with no new syntax.<br>
1. Make a normal function into a generator or coroutine. This can be done with a decorator.<br>
2. Support a parallel set of special methods starting with 'a' or 'async'. Why not just use the current set of special methods?<br>
3. "await". "await" is an operator that takes one argument and produces a single result, without altering flow control and can thus be replaced by an function.<br>
4. Asynchronous with statement. The PEP lists the equivalent as "with (yield from xxx)" which doesn't seem so bad.<br>
<br>
Please don't add unnecessary new syntax.<br>
<br>
Cheers,<br>
Mark.<br>
<br>
P.S. I'm not objecting to any of the other new features proposed, just the new syntax.<br>
_______________________________________________<br>
Python-Dev mailing list<br>
<a href="mailto:Python-Dev@python.org" target="_blank">Python-Dev@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-dev" target="_blank">https://mail.python.org/mailman/listinfo/python-dev</a><br>
Unsubscribe: <a href="https://mail.python.org/mailman/options/python-dev/yoavglazner%40gmail.com" target="_blank">https://mail.python.org/mailman/options/python-dev/yoavglazner%40gmail.com</a><br>
</blockquote></div><br></div>