Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1e170ba

Browse files
committed
#1554133: Document PyOS_InputHook, PyOS_ReadlineFunctionPointer
1 parent 6750282 commit 1e170ba

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

Doc/c-api/veryhigh.rst

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,29 @@ the same library that the Python runtime is using.
144144
(:func:`sys.getfilesystemencoding`). Returns ``0`` at EOF.
145145
146146
147+
.. c:var:: int (*PyOS_InputHook)(void)
148+
149+
Can be set to point to a function with the prototype
150+
``int func(void)``. The function will be called when Python's
151+
interpreter prompt is about to become idle and wait for user input
152+
from the terminal. The return value is ignored. Overriding this
153+
hook can be used to integrate the interpreter's prompt with other
154+
event loops, as done in the :file:`Modules/_tkinter.c` in the
155+
Python source code.
156+
157+
158+
.. c:var:: char* (*PyOS_ReadlineFunctionPointer)(FILE *, FILE *, char *)
159+
160+
Can be set to point to a function with the prototype
161+
``char *func(FILE *stdin, FILE *stdout, char *prompt)``,
162+
overriding the default function used to read a single line of input
163+
at the interpreter's prompt. The function is expected to output
164+
the string *prompt* if it's not *NULL*, and then read a line of
165+
input from the provided standard input file, returning the
166+
resulting string. For example, The :mod:`readline` module sets
167+
this hook to provide line-editing and tab-completion features.
168+
169+
147170
.. c:function:: struct _node* PyParser_SimpleParseString(const char *str, int start)
148171
149172
This is a simplified interface to
@@ -338,4 +361,3 @@ the same library that the Python runtime is using.
338361
339362
This bit can be set in *flags* to cause division operator ``/`` to be
340363
interpreted as "true division" according to :pep:`238`.
341-

0 commit comments

Comments
 (0)