Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
0dc23101
Commit
0dc23101
authored
May 23, 2004
by
Skip Montanaro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exposed readline() function from the readline module.
parent
ddc819c9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
Doc/lib/libreadline.tex
Doc/lib/libreadline.tex
+5
-0
Misc/NEWS
Misc/NEWS
+5
-0
Modules/readline.c
Modules/readline.c
+23
-0
No files found.
Doc/lib/libreadline.tex
View file @
0dc23101
...
...
@@ -15,6 +15,10 @@ interpreter.
The
\module
{
readline
}
module defines the following functions:
\begin{funcdesc}
{
readline
}{
\optional
{
prompt
}}
Get a single line of input from the user.
\end{funcdesc}
\begin{funcdesc}
{
parse
_
and
_
bind
}{
string
}
Parse and execute single line of a readline init file.
\end{funcdesc}
...
...
@@ -154,3 +158,4 @@ import atexit
atexit.register(readline.write
_
history
_
file, histfile)
del os, histfile
\end{verbatim}
Misc/NEWS
View file @
0dc23101
...
...
@@ -207,6 +207,11 @@ Core and builtins
Extension modules
-----------------
- The readline module now exposes the readline() function to the Python
programmer. readline.readline() should be a drop-in replacement for
raw_input() but coupled with the other readline module functionality allow
programmers to offer history and input recall to their users.
- operator.isMappingType() and operator.isSequenceType() now give
fewer false positives.
...
...
Modules/readline.c
View file @
0dc23101
...
...
@@ -32,6 +32,28 @@
#endif
/* Exported function to get a line from the user */
static
PyObject
*
py_readline
(
PyObject
*
self
,
PyObject
*
args
)
{
char
*
s
=
NULL
;
char
*
line
=
NULL
;
if
(
!
PyArg_ParseTuple
(
args
,
"|s:readline"
,
&
s
))
return
NULL
;
line
=
readline
(
s
);
if
(
line
==
NULL
)
{
PyErr_SetString
(
PyExc_EOFError
,
"End of file on input"
);
return
NULL
;
}
return
PyString_FromString
(
line
);
}
PyDoc_STRVAR
(
doc_py_readline
,
"readline([prompt]) -> line
\n
\
Prompt for and read a line of text. Raise EOFError on EOF."
);
/* Exported function to send one line to readline's init file parser */
static
PyObject
*
...
...
@@ -468,6 +490,7 @@ contents of the line buffer.");
static
struct
PyMethodDef
readline_methods
[]
=
{
{
"readline"
,
py_readline
,
METH_VARARGS
,
doc_py_readline
},
{
"parse_and_bind"
,
parse_and_bind
,
METH_VARARGS
,
doc_parse_and_bind
},
{
"get_line_buffer"
,
get_line_buffer
,
METH_NOARGS
,
doc_get_line_buffer
},
{
"insert_text"
,
insert_text
,
METH_VARARGS
,
doc_insert_text
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment