Skip to content

Instantly share code, notes, and snippets.

@BurhanH
Created February 22, 2019 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BurhanH/0c90d63cd32466556d5e81c869d6a389 to your computer and use it in GitHub Desktop.
Save BurhanH/0c90d63cd32466556d5e81c869d6a389 to your computer and use it in GitHub Desktop.
How to use a lambda expression as an asynchronous function
import asyncio
f = asyncio.coroutine(lambda x: x**2)
asyncio.get_event_loop().run_until_complete(f(12))
# 144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment