跳转到主要内容

为IPython定义一个async_magic,以在顶层模拟async关键字

项目描述

IPython Async_magic

顶层repl的异步!

In [1]: import aiohttp

In [2]: res = await aiohttp.get('https://api.github.com')
  File "<ipython-input-2-52b78a6e45a0>", line 1
    res = await aiohttp.get('https://api.github.com')
                      ^
SyntaxError: invalid syntax


In [3]: %load_ext async_magic

In [4]: res = %await aiohttp.get('https://api.github.com')

In [5]: await res.json()
Out[5]:
{'authorizations_url': 'https://api.github.com/authorizations',
 'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}',
 'commit_search_url': 'https://api.github.com/search/commits?q={query}{&page,per_page,sort,order}',
 'current_user_authorizations_html_url': 'https://github.com/settings/connections/applications{/client_id}',
 'current_user_repositories_url': 'https://api.github.com/user/repos{?type,page,per_page,sort}',
 'current_user_url': 'https://api.github.com/user',
 'emails_url': 'https://api.github.com/user/emails',
 'emojis_url': 'https://api.github.com/emojis',
 ...
}

注意%res = %await aiohttp.get('https://api.github.com')中的赋值

更改循环

使用%loop <loop>

项目详情


下载文件

下载适用于您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。

源分布

此版本没有可用的源分布文件。有关生成分布存档的教程,请参阅此处

构建分布

async_magic-0.0.1-py3-none-any.whl (31.0 kB 查看哈希值)

上传时间: Python 3

由以下机构支持

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误日志 StatusPage StatusPage 状态页面