You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.rst
+32-9Lines changed: 32 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,37 @@ aioconsole_ provides:
14
14
* `stream`_ support to serve interfaces instead of using standard streams
15
15
* the ``apython`` script to access asyncio code at runtime without modifying the sources
16
16
17
+
⚠️ Limitations
18
+
--------------
19
+
20
+
Better alternative to ``aioconsole.ainput()``
21
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22
+
23
+
A common use case for aioconsole is the async alternative to the builtin `input`_ function.
24
+
However, aioconsole_ was written in 2015 and since then the powerful prompt-toolkit_ library has gained better asyncio support.
25
+
The recommended way to `prompt in an asyncio application <https://python-prompt-toolkit.readthedocs.io/en/master/pages/asking_for_input.html#prompt-in-an-asyncio-application>`_ is now to use the `prompt_toolkit`_ library:
26
+
27
+
.. code:: python3
28
+
29
+
from prompt_toolkit import PromptSession
30
+
from prompt_toolkit.patch_stdout import patch_stdout
31
+
32
+
async def my_coroutine():
33
+
session = PromptSession()
34
+
while True:
35
+
with patch_stdout():
36
+
result = await session.prompt_async("Say something: ")
37
+
print(f"You said: {result}")
38
+
39
+
40
+
Better python consoles with async support
41
+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
42
+
43
+
The python console exposed by `aioconsole`_ is quite limited compared to modern consoles such as `IPython`_ or `ptpython`_. Luckily, those projects gained greater asyncio support over the years. In particular, the following use cases overlap with `aioconsole`_ capabilities:
44
+
45
+
- `Embedding a ptpython console in an asyncio program <https://github.com/prompt-toolkit/ptpython/blob/master/examples/asyncio-python-embed.py>`_
46
+
- `Using the await syntax in an IPython console <https://ipython.readthedocs.io/en/stable/whatsnew/version7.html#autowait-asynchronous-repl>`_
47
+
17
48
18
49
Requirements
19
50
------------
@@ -87,15 +118,6 @@ Documentation
87
118
Find more examples in the documentation_ and the `example directory`_.
88
119
89
120
90
-
Limitations
91
-
-----------
92
-
93
-
The python console exposed by `aioconsole`_ is quite limited compared to modern consoles such as `IPython`_ or `ptpython`_. Luckily, those projects gained greater asyncio support over the years. In particular, the following use cases overlap with `aioconsole`_ capabilities:
94
-
95
-
- `Embedding a ptpython console in an asyncio program <https://github.com/prompt-toolkit/ptpython/blob/master/examples/asyncio-python-embed.py>`_
96
-
- `Using the await syntax in an IPython console <https://ipython.readthedocs.io/en/stable/whatsnew/version7.html#autowait-asynchronous-repl>`_
0 commit comments