Created
September 24, 2021 07:38
-
-
Save sileht/153b347efe257981c05881bede3337a1 to your computer and use it in GitHub Desktop.
dict-comprenhension-await.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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