This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author hniksic
Recipients hniksic
Date 2020-06-29.14:50:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Originally brought up on StackOverflow, :

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
Date User Action Args
2020-06-29 14:50:41hniksicsetrecipients: + hniksic
2020-06-29 14:50:41hniksicsetmessageid: <>
2020-06-29 14:50:41hniksiclinkissue41159 messages
2020-06-29 14:50:41hniksiccreate