[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot
Roel van der Goot added the comment: Thank you! -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Zachary Ware
Zachary Ware added the comment: That's already provided, just do `return outputs` instead of `print(outputs)`, and `outputs = event_loop.run_until_complete(main())`. See https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop.run_until_complete --

[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot
Roel van der Goot added the comment: I have been thinking about my previous comment a bit more. For consistency there should at least be an await somewhere to move back from async land to non-async land. For example: #!/usr/bin/env python3 import asyncio async def main():

[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot
Roel van der Goot added the comment: Zachary, Thank you for your response. I had the impression that async comprehensions are a bridge between async functions and non-async functions. Is there a wat to use async (and asyncio) and then go back to regular python? Or am I just wishful thinking?

[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Zachary Ware
Zachary Ware added the comment: Your async listcomp must also be defined within a coroutine to turn `async` into a keyword in 3.6. The following is far from best practice (don't do this, I don't know what I'm doing! :), but at least it compiles and shows that it works: async def arange(n):

[issue31832] Async list comprehension (PEP 530) causes SyntaxError in Python 3.6.3

2017-10-20 Thread Roel van der Goot
New submission from Roel van der Goot : $ python3 Python 3.6.3 (default, Oct 3 2017, 21:45:48) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> async def arange(n): ... for i in range(n): ... yield i ... >>> [i async for i in arange(10