[New-bugs-announce] [issue33346] Syntax error with async generator inside dictionary comprehension
Pablo Galindo Salgado
report at bugs.python.org
Tue Apr 24 07:05:41 EDT 2018
New submission from Pablo Galindo Salgado <pablogsal at gmail.com>:
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 <report at bugs.python.org>
<https://bugs.python.org/issue33346>
_______________________________________
More information about the New-bugs-announce
mailing list