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 levkivskyi
Recipients gvanrossum, levkivskyi, vstinner, yselivanov
Date 2015-06-29.11:28:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The following code:

async def foo():
    lst = [await coro(i) for i in range(10)]
    return lst


SyntaxError: 'await' outside async function

I understand that this is because the comprehensions are implemented using a function scope (see also #10544), but such behavior is unintuitive.

IMO there are two possibilities here:
1) make comprehensions behave more like a for loop;
2) change the exception text to something like "SyntaxError: 'await's in comprehensions are not supported".

I understand that the first option is probably not for 3.5 (it is beta already), but I will be happy if the second option will be implemented in 3.5
Date User Action Args
2015-06-29 11:28:43levkivskyisetrecipients: + levkivskyi, gvanrossum, vstinner, yselivanov
2015-06-29 11:28:43levkivskyisetmessageid: <>
2015-06-29 11:28:43levkivskyilinkissue24528 messages
2015-06-29 11:28:42levkivskyicreate