New submission from Pablo Galindo Salgado <[email protected]>:
Given this async function:
async def elements(n):
yield n
yield n*2
yield n*3
yield n*4
This definition is considered invalid:
async def test():
return { n: [x async for x in elements(n)] for n in range(3)}
SyntaxError: asynchronous comprehension outside of an asynchronous function
The reason (I suspect) is because the dict comprehension is not an async
context (it would be if range was an async iterable and we use `async for n in
range(3)`).
Is this expected behaviour or something it needs to change?
----------
components: asyncio
messages: 315692
nosy: asvetlov, pablogsal, yselivanov
priority: normal
severity: normal
status: open
title: Syntax error with async generator inside dictionary comprehension
type: behavior
versions: Python 3.7
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue33346>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com