summaryrefslogtreecommitdiffstats
path: root/Doc/lib
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-17 06:49:51 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-17 06:49:51 (GMT)
commitce96f69d69a6020c780145c89a17a8391b63624b (patch)
tree7325a9bfaddf191e49910532df1fa4210c335196 /Doc/lib
parent9e2b9665ae9f94a07da54156c48e2cd411a23746 (diff)
downloadcpython-ce96f69d69a6020c780145c89a17a8391b63624b.zip
cpython-ce96f69d69a6020c780145c89a17a8391b63624b.tar.gz
cpython-ce96f69d69a6020c780145c89a17a8391b63624b.tar.bz2
Get rid of a bunch more raw_input references
Diffstat (limited to 'Doc/lib')
-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
9 files changed, 28 insertions, 58 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()