diff options
Diffstat (limited to 'Doc/lib')
-rw-r--r-- | Doc/lib/libcmd.tex | 10 | ||||
-rw-r--r-- | Doc/lib/libcode.tex | 4 | ||||
-rw-r--r-- | Doc/lib/libcrypt.tex | 6 | ||||
-rw-r--r-- | Doc/lib/libexcs.tex | 7 | ||||
-rw-r--r-- | Doc/lib/libfuncs.tex | 35 | ||||
-rw-r--r-- | Doc/lib/libsmtplib.tex | 6 | ||||
-rw-r--r-- | Doc/lib/libsys.tex | 7 | ||||
-rw-r--r-- | Doc/lib/libtelnetlib.tex | 5 | ||||
-rw-r--r-- | Doc/lib/libtermios.tex | 6 |
9 files changed, 28 insertions, 58 deletions
diff --git a/Doc/lib/libcmd.tex b/Doc/lib/libcmd.tex index 661eb9e45c..9fe8123808 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 dc4c717ad8..628a1eb735 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 b6a14635b5..55e716354a 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 f52ff0a952..85058a414e 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 9b6bfe9d7b..c75c172a60 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 2f87bc483b..ddf17649c7 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 ea8950a847..1a57da4b37 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 c7a4226dcc..b8dfeee2e0 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 ef99cf9ede..64f3438a0f 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() |