New submission from Ivan Levkivskyi: The following code:
async def foo(): lst = [await coro(i) for i in range(10)] return lst gives 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 ---------- components: Interpreter Core, asyncio messages: 245931 nosy: gvanrossum, haypo, levkivskyi, yselivanov priority: normal severity: normal status: open title: Misleading exeption for await in comprehensions. type: behavior versions: Python 3.5, Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24528> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com