New submission from Hrvoje Nikšić <hnik...@gmail.com>:

Originally brought up on StackOverflow, 
https://stackoverflow.com/questions/60799366/nested-async-comprehension :

This dict comprehension parses and works correctly:

async def bar():
    return {
        n: await foo(n) for n in [1, 2, 3]
    }

But making it nested fails with a SyntaxError:

async def bar():
    return {
        i: {
            n: await foo(n) for n in [1, 2, 3]
        } for i in [1,2,3]
    }

The error reported is:

  File "<stdin>", line 0
SyntaxError: asynchronous comprehension outside of an asynchronous function

----------
components: Interpreter Core
messages: 372582
nosy: hniksic
priority: normal
severity: normal
status: open
title: Nested async dict comprehension fails with SyntaxError
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41159>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to