Skip to content

Instantly share code, notes, and snippets.

@sileht
Created September 24, 2021 07:38
Show Gist options
  • Save sileht/153b347efe257981c05881bede3337a1 to your computer and use it in GitHub Desktop.
Save sileht/153b347efe257981c05881bede3337a1 to your computer and use it in GitHub Desktop.
dict-comprenhension-await.py
import asyncio
async def compute(i):
await asyncio.sleep(0)
return i + 1
async def main():
items = ["a", "b", "c"]
return [
{
i: await compute(n)
for n in range(0, 10)
}
for i in items
]
print(asyncio.run(main()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment