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

Skip to content

Commit f96e0d2

Browse files
committed
Various clarifications and minor nits fixed. Affected descriptions of
input(), locals(), reload(), unicode(), and zip().
1 parent 1172a85 commit f96e0d2

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

Doc/lib/libfuncs.tex

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,19 @@ \section{Built-in Functions \label{built-in-funcs}}
310310

311311
\begin{funcdesc}{input}{\optional{prompt}}
312312
Equivalent to \code{eval(raw_input(\var{prompt}))}.
313+
\strong{Warning:} This function is not safe from user errors! It
314+
expects a valid Python expression as input; if the input is not
315+
syntactically valid, a \exception{SyntaxError} will be raised.
316+
Other exceptions may be raised if there is an error during
317+
evaluation. (On the other hand, sometimes this is exactly what you
318+
need when writing a quick script for expert use.)
319+
320+
If the \module{readline} module was loaded, then
321+
\function{input()} will use it to provide elaborate line editing and
322+
history features.
323+
324+
Consider using the \function{raw_input()} function for general input
325+
from users.
313326
\end{funcdesc}
314327

315328
\begin{funcdesc}{int}{x\optional{, radix}}
@@ -374,7 +387,7 @@ \section{Built-in Functions \label{built-in-funcs}}
374387

375388
\begin{funcdesc}{locals}{}
376389
Return a dictionary representing the current local symbol table.
377-
\strong{Warning:} the contents of this dictionary should not be
390+
\strong{Warning:} The contents of this dictionary should not be
378391
modified; changes may not affect the values of local variables used by
379392
the interpreter.
380393
\end{funcdesc}
@@ -574,7 +587,7 @@ \section{Built-in Functions \label{built-in-funcs}}
574587

575588
It is legal though generally not very useful to reload built-in or
576589
dynamically loaded modules, except for \module{sys}, \module{__main__}
577-
and \module{__builtin__}. In certain cases, however, extension
590+
and \module{__builtin__}. In many cases, however, extension
578591
modules are not designed to be initialized more than once, and may
579592
fail in arbitrary ways when reloaded.
580593

@@ -669,11 +682,11 @@ \section{Built-in Functions \label{built-in-funcs}}
669682
\versionadded{2.0}
670683
\end{funcdesc}
671684

672-
\begin{funcdesc}{unicode}{string\optional{, encoding='utf-8'\optional{, errors='strict'}}}
685+
\begin{funcdesc}{unicode}{string\optional{, encoding\optional{, errors}}}
673686
Decodes \var{string} using the codec for \var{encoding}. Error
674687
handling is done according to \var{errors}. The default behavior is
675688
to decode UTF-8 in strict mode, meaning that encoding errors raise
676-
\exception{ValueError}.
689+
\exception{ValueError}. See also the \refmodule{codecs} module.
677690
\versionadded{2.0}
678691
\end{funcdesc}
679692

@@ -706,8 +719,9 @@ \section{Built-in Functions \label{built-in-funcs}}
706719
\var{i}-th element from each of the argument sequences. At least one
707720
sequence is required, otherwise a \exception{TypeError} is raised.
708721
The returned list is truncated in length to the length of the shortest
709-
argument sequence. When the argument sequences are all of the same
710-
length, \function{zip()} is similar to \function{map()} with an
711-
initial argument of \code{None}.
722+
argument sequence. When there are multiple argument sequences which
723+
are all of the same length, \function{zip()} is similar to
724+
\function{map()} with an initial argument of \code{None}. With a
725+
single sequence argument, it returns a list of 1-tuples.
712726
\versionadded{2.0}
713727
\end{funcdesc}

0 commit comments

Comments
 (0)