summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/lib/libcmd.tex10
-rw-r--r--Doc/lib/libcode.tex4
-rw-r--r--Doc/lib/libcrypt.tex6
-rw-r--r--Doc/lib/libexcs.tex7
-rw-r--r--Doc/lib/libfuncs.tex35
-rw-r--r--Doc/lib/libsmtplib.tex6
-rw-r--r--Doc/lib/libsys.tex7
-rw-r--r--Doc/lib/libtelnetlib.tex5
-rw-r--r--Doc/lib/libtermios.tex6
-rw-r--r--Doc/ref/ref8.tex5
-rw-r--r--Doc/tools/keywords.py6
-rw-r--r--Doc/tut/tut.tex33
12 files changed, 63 insertions, 67 deletions
diff --git a/Doc/lib/libcmd.tex b/Doc/lib/libcmd.tex
index 661eb9e..9fe8123 100644
--- a/Doc/lib/libcmd.tex
+++ b/Doc/lib/libcmd.tex
@@ -186,13 +186,3 @@ The character used to draw separator lines under the help-message
headers. If empty, no ruler line is drawn. It defaults to
\character{=}.
\end{memberdesc}
-
-\begin{memberdesc}{use_rawinput}
-A flag, defaulting to true. If true, \method{cmdloop()} uses
-\function{raw_input()} to display a prompt and read the next command;
-if false, \method{sys.stdout.write()} and
-\method{sys.stdin.readline()} are used. (This means that by
-importing \refmodule{readline}, on systems that support it, the
-interpreter will automatically support \program{Emacs}-like line editing
-and command-history keystrokes.)
-\end{memberdesc}
diff --git a/Doc/lib/libcode.tex b/Doc/lib/libcode.tex
index dc4c717..628a1eb 100644
--- a/Doc/lib/libcode.tex
+++ b/Doc/lib/libcode.tex
@@ -167,7 +167,7 @@ Remove any unhandled source text from the input buffer.
\begin{methoddesc}{raw_input}{\optional{prompt}}
Write a prompt and read a line. The returned line does not include
the trailing newline. When the user enters the \EOF{} key sequence,
-\exception{EOFError} is raised. The base implementation uses the
-built-in function \function{raw_input()}; a subclass may replace this
+\exception{EOFError} is raised. The base implementation reads from
+\code{sys.stdin}; a subclass may replace this
with a different implementation.
\end{methoddesc}
diff --git a/Doc/lib/libcrypt.tex b/Doc/lib/libcrypt.tex
index b6a1463..55e7163 100644
--- a/Doc/lib/libcrypt.tex
+++ b/Doc/lib/libcrypt.tex
@@ -41,6 +41,12 @@ A simple example illustrating typical use:
\begin{verbatim}
import crypt, getpass, pwd
+def raw_input(prompt):
+ import sys
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def login():
username = raw_input('Python login:')
cryptedpasswd = pwd.getpwnam(username)[1]
diff --git a/Doc/lib/libexcs.tex b/Doc/lib/libexcs.tex
index f52ff0a..85058a4 100644
--- a/Doc/lib/libexcs.tex
+++ b/Doc/lib/libexcs.tex
@@ -153,9 +153,7 @@ Raised when an \keyword{assert} statement fails.
\begin{excdesc}{EOFError}
% XXXJH xrefs here
- Raised when one of the built-in functions (\function{input()} or
- \function{raw_input()}) hits an end-of-file condition (\EOF) without
- reading any data.
+ Raised when attempting to read beyond the end of a file.
% XXXJH xrefs here
(N.B.: the \method{read()} and \method{readline()} methods of file
objects return an empty string when they hit \EOF.)
@@ -213,9 +211,6 @@ Raised when an \keyword{assert} statement fails.
\kbd{Control-C} or \kbd{Delete}). During execution, a check for
interrupts is made regularly.
% XXX(hylton) xrefs here
- Interrupts typed when a built-in function \function{input()} or
- \function{raw_input()} is waiting for input also raise this
- exception.
The exception inherits from \exception{BaseException} so as to not be
accidentally caught by code that catches \exception{Exception} and thus
prevent the interpreter from exiting.
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index 9b6bfe9..c75c172 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -551,23 +551,6 @@ class C:
note: this is the address of the object.)
\end{funcdesc}
-\begin{funcdesc}{input}{\optional{prompt}}
- Equivalent to \code{eval(raw_input(\var{prompt}))}.
- \warning{This function is not safe from user errors! It
- expects a valid Python expression as input; if the input is not
- syntactically valid, a \exception{SyntaxError} will be raised.
- Other exceptions may be raised if there is an error during
- evaluation. (On the other hand, sometimes this is exactly what you
- need when writing a quick script for expert use.)}
-
- If the \refmodule{readline} module was loaded, then
- \function{input()} will use it to provide elaborate line editing and
- history features.
-
- Consider using the \function{raw_input()} function for general input
- from users.
-\end{funcdesc}
-
\begin{funcdesc}{int}{\optional{x\optional{, radix}}}
Convert a string or number to a plain integer. If the argument is a
string, it must contain a possibly signed decimal number
@@ -811,24 +794,6 @@ class C(object):
\end{verbatim}
\end{funcdesc}
-\begin{funcdesc}{raw_input}{\optional{prompt}}
- If the \var{prompt} argument is present, it is written to standard output
- without a trailing newline. The function then reads a line from input,
- converts it to a string (stripping a trailing newline), and returns that.
- When \EOF{} is read, \exception{EOFError} is raised. Example:
-
-\begin{verbatim}
->>> s = raw_input('--> ')
---> Monty Python's Flying Circus
->>> s
-"Monty Python's Flying Circus"
-\end{verbatim}
-
- If the \refmodule{readline} module was loaded, then
- \function{raw_input()} will use it to provide elaborate
- line editing and history features.
-\end{funcdesc}
-
\begin{funcdesc}{reduce}{function, sequence\optional{, initializer}}
Apply \var{function} of two arguments cumulatively to the items of
\var{sequence}, from left to right, so as to reduce the sequence to
diff --git a/Doc/lib/libsmtplib.tex b/Doc/lib/libsmtplib.tex
index 2f87bc4..ddf1764 100644
--- a/Doc/lib/libsmtplib.tex
+++ b/Doc/lib/libsmtplib.tex
@@ -267,6 +267,12 @@ processing of the \rfc{822} headers. In particular, the `To' and
\begin{verbatim}
import smtplib
+def raw_input(prompt):
+ import sys
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def prompt(prompt):
return raw_input(prompt).strip()
diff --git a/Doc/lib/libsys.tex b/Doc/lib/libsys.tex
index ea8950a..1a57da4 100644
--- a/Doc/lib/libsys.tex
+++ b/Doc/lib/libsys.tex
@@ -511,11 +511,8 @@ else:
\dataline{stderr}
File objects corresponding to the interpreter's standard input,
output and error streams. \code{stdin} is used for all interpreter
- input except for scripts but including calls to
- \function{input()}\bifuncindex{input} and
- \function{raw_input()}\bifuncindex{raw_input}. \code{stdout} is
- used for the output of \keyword{print} and expression statements and
- for the prompts of \function{input()} and \function{raw_input()}.
+ input except for scripts. \code{stdout} is
+ used for the output of \keyword{print} and expression statements.
The interpreter's own prompts and (almost all of) its error messages
go to \code{stderr}. \code{stdout} and \code{stderr} needn't be
built-in file objects: any object is acceptable as long as it has a
diff --git a/Doc/lib/libtelnetlib.tex b/Doc/lib/libtelnetlib.tex
index c7a4226..b8dfeee 100644
--- a/Doc/lib/libtelnetlib.tex
+++ b/Doc/lib/libtelnetlib.tex
@@ -196,6 +196,11 @@ import getpass
import sys
import telnetlib
+def raw_input(prompt):
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
HOST = "localhost"
user = raw_input("Enter your remote account: ")
password = getpass.getpass()
diff --git a/Doc/lib/libtermios.tex b/Doc/lib/libtermios.tex
index ef99cf9..64f3438 100644
--- a/Doc/lib/libtermios.tex
+++ b/Doc/lib/libtermios.tex
@@ -91,6 +91,12 @@ and a \keyword{try} ... \keyword{finally} statement to ensure that the
old tty attributes are restored exactly no matter what happens:
\begin{verbatim}
+def raw_input(prompt):
+ import sys
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def getpass(prompt = "Password: "):
import termios, sys
fd = sys.stdin.fileno()
diff --git a/Doc/ref/ref8.tex b/Doc/ref/ref8.tex
index d10c87f..801ab58 100644
--- a/Doc/ref/ref8.tex
+++ b/Doc/ref/ref8.tex
@@ -103,10 +103,7 @@ The input line read by \function{input()} must have the following form:
\end{productionlist}
Note: to read `raw' input line without interpretation, you can use the
-built-in function \function{raw_input()} or the \method{readline()} method
-of file objects.
+the \method{readline()} method of file objects, including \code{sys.stdin}.
\obindex{file}
\index{input!raw}
-\index{raw input}
-\bifuncindex{raw_input}
\withsubitem{(file method)}{\ttindex{readline()}}
diff --git a/Doc/tools/keywords.py b/Doc/tools/keywords.py
index 9f32056..3344021 100644
--- a/Doc/tools/keywords.py
+++ b/Doc/tools/keywords.py
@@ -2,6 +2,12 @@
# This Python program sorts and reformats the table of keywords in ref2.tex
+def raw_input(prompt):
+ import sys
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
l = []
try:
while 1:
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex
index efbc08d..054985b 100644
--- a/Doc/tut/tut.tex
+++ b/Doc/tut/tut.tex
@@ -231,7 +231,7 @@ full name on the command line.
Note that there is a difference between \samp{python file} and
\samp{python <file}. In the latter case, input requests from the
-program, such as calls to \function{input()} and \function{raw_input()}, are
+program, such as calling \code{sys.stdin.read()}, are
satisfied from \emph{file}. Since this file has already been read
until the end by the parser before the program starts executing, the
program will encounter end-of-file immediately. In the former case
@@ -1161,6 +1161,12 @@ Perhaps the most well-known statement type is the
\keyword{if} statement. For example:
\begin{verbatim}
+>>> def raw_input(prompt):
+... import sys
+... sys.stdout.write(prompt)
+... sys.stdout.flush()
+... return sys.stdin.readline()
+...
>>> x = int(raw_input("Please enter an integer: "))
>>> if x < 0:
... x = 0
@@ -1453,6 +1459,12 @@ arguments. This creates a function that can be called with fewer
arguments than it is defined to allow. For example:
\begin{verbatim}
+def raw_input(prompt):
+ import sys
+ sys.stdout.write(prompt)
+ sys.stdout.flush()
+ return sys.stdin.readline()
+
def ask_ok(prompt, retries=4, complaint='Yes or no, please!'):
while True:
ok = raw_input(prompt)
@@ -2711,15 +2723,15 @@ standard module \module{__builtin__}\refbimodindex{__builtin__}:
'UnicodeEncodeError', 'UnicodeError', 'UnicodeTranslateError',
'UserWarning', 'ValueError', 'Warning', 'WindowsError',
'ZeroDivisionError', '_', '__debug__', '__doc__', '__import__',
- '__name__', 'abs', 'apply', 'basestring', 'bool', 'buffer',
+ '__name__', 'abs', 'basestring', 'bool', 'buffer',
'callable', 'chr', 'classmethod', 'cmp', 'coerce', 'compile',
'complex', 'copyright', 'credits', 'delattr', 'dict', 'dir', 'divmod',
'enumerate', 'eval', 'execfile', 'exit', 'file', 'filter', 'float',
'frozenset', 'getattr', 'globals', 'hasattr', 'hash', 'help', 'hex',
- 'id', 'input', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
+ 'id', 'int', 'intern', 'isinstance', 'issubclass', 'iter',
'len', 'license', 'list', 'locals', 'long', 'map', 'max', 'min',
'object', 'oct', 'open', 'ord', 'pow', 'property', 'quit', 'range',
- 'raw_input', 'reduce', 'reload', 'repr', 'reversed', 'round', 'set',
+ 'reduce', 'reload', 'repr', 'reversed', 'round', 'set',
'setattr', 'slice', 'sorted', 'staticmethod', 'str', 'sum', 'super',
'tuple', 'type', 'unichr', 'unicode', 'vars', 'xrange', 'zip']
\end{verbatim}
@@ -3412,6 +3424,12 @@ supports); note that a user-generated interruption is signalled by
raising the \exception{KeyboardInterrupt} exception.
\begin{verbatim}
+>>> def raw_input(prompt):
+... import sys
+... sys.stdout.write(prompt)
+... sys.stdout.flush()
+... return sys.stdin.readline()
+...
>>> while True:
... try:
... x = int(raw_input("Please enter a number: "))
@@ -4983,7 +5001,12 @@ renaming utility for a photo browser may elect to use percent signs for
placeholders such as the current date, image sequence number, or file format:
\begin{verbatim}
->>> import time, os.path
+>>> import time, os.path, sys
+>>> def raw_input(prompt):
+... sys.stdout.write(prompt)
+... sys.stdout.flush()
+... return sys.stdin.readline()
+...
>>> photofiles = ['img_1074.jpg', 'img_1076.jpg', 'img_1077.jpg']
>>> class BatchRename(Template):
... delimiter = '%'