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 <1593442241.74.0.468196599971.issue41159@roundup.psfhosted.org>
In-reply-to
Content
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
History
Date User Action Args
2020-06-29 14:50:41hniksicsetrecipients: + hniksic
2020-06-29 14:50:41hniksicsetmessageid: <1593442241.74.0.468196599971.issue41159@roundup.psfhosted.org>
2020-06-29 14:50:41hniksiclinkissue41159 messages
2020-06-29 14:50:41hniksiccreate