async-chain-0.1.2
توضیحات
A coroutine builder
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | async-chain-0.1.2 |
| نام | async-chain |
| نسخه کتابخانه | 0.1.2 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Stefano Pigozzi |
| ایمیل نویسنده | me@steffo.eu |
| آدرس صفحه اصلی | https://github.com/Steffo99/async-chain |
| آدرس اینترنتی | https://pypi.org/project/async-chain/ |
| مجوز | LGPL-3.0-or-later |
# `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?
```python
async def on_message(event):
message = await event.get_message()
author = await message.get_author()
await author.send_message("Hello world!")
```
Or even worse:
```python
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!
```python
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:
```console
$ pip install async_chain
```
```console
$ pipenv install async_chain
```
```console
$ 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!
```python
import async_chain
class MyEvent:
@async_chain.method
async def get_message(self):
...
```
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6,<4.0 | Python |
نحوه نصب
نصب پکیج whl async-chain-0.1.2:
pip install async-chain-0.1.2.whl
نصب پکیج tar.gz async-chain-0.1.2:
pip install async-chain-0.1.2.tar.gz