A coroutine builder
Project description
async-chain
A coroutine builder
What?
Have you ever felt that the await
syntax in Python was a bit clunky when chaining multiple methods together?
async def on_message(event):
message = await event.get_message()
author = await message.get_author()
await author.send_message("Hello world!")
Or even worse:
async def on_message(event):
(await (await (await event.get_message()).get_author()).send_message("Hello world!"))
async-chain
is here to solve your problem!
async def on_message(event):
await event.get_message().get_author().send_message("Hello world!")
How?
First, install async_chain
with your favorite package manager:
$ pip install async_chain
$ pipenv install async_chain
$ poetry add async_chain
Then, add the @async_chain.method
decorator to any async method you wish to make chainable, and the problem will be
magically solved!
import async_chain
class MyEvent:
@async_chain.method
async def get_message(self):
...
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
async-chain-0.1.1.tar.gz
(5.9 kB
view hashes)
Built Distribution
Close
Hashes for async_chain-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 670110bc711b987f7c4778bf9553110ac17038d7c574414bfcd3c450647e234e |
|
MD5 | 4d64afaade9ed7e77566f2012d238017 |
|
BLAKE2b-256 | 1e7160448bfddd223c71993a88c0bc64be543bb2882063aaf86528e1af9aef08 |