mirror of
https://github.com/python/cpython.git
synced 2025-07-31 23:23:11 +00:00
Mention dict.fromkeys()
Various edits
This commit is contained in:
parent
5ef2b214cd
commit
b492fa9101
1 changed files with 29 additions and 18 deletions
|
@ -615,11 +615,11 @@ characters may be encountered. So far, Python has allowed specifying
|
||||||
the error processing as either ``strict'' (raising
|
the error processing as either ``strict'' (raising
|
||||||
\exception{UnicodeError}), ``ignore'' (skip the character), or
|
\exception{UnicodeError}), ``ignore'' (skip the character), or
|
||||||
``replace'' (with question mark), defaulting to ``strict''. It may be
|
``replace'' (with question mark), defaulting to ``strict''. It may be
|
||||||
desirable to specify an alternative processing of the error, e.g. by
|
desirable to specify an alternative processing of the error, such as
|
||||||
inserting an XML character reference or HTML entity reference into the
|
inserting an XML character reference or HTML entity reference into the
|
||||||
converted string.
|
converted string.
|
||||||
|
|
||||||
Python now has a flexible framework to add additional processing
|
Python now has a flexible framework to add different processing
|
||||||
strategies. New error handlers can be added with
|
strategies. New error handlers can be added with
|
||||||
\function{codecs.register_error}. Codecs then can access the error
|
\function{codecs.register_error}. Codecs then can access the error
|
||||||
handler with \function{codecs.lookup_error}. An equivalent C API has
|
handler with \function{codecs.lookup_error}. An equivalent C API has
|
||||||
|
@ -631,7 +631,7 @@ replacement string.
|
||||||
|
|
||||||
Two additional error handlers have been implemented using this
|
Two additional error handlers have been implemented using this
|
||||||
framework: ``backslashreplace'' uses Python backslash quoting to
|
framework: ``backslashreplace'' uses Python backslash quoting to
|
||||||
represent the unencodable character, and ``xmlcharrefreplace'' emits
|
represent unencodable characters and ``xmlcharrefreplace'' emits
|
||||||
XML character references.
|
XML character references.
|
||||||
|
|
||||||
\begin{seealso}
|
\begin{seealso}
|
||||||
|
@ -821,7 +821,13 @@ KeyError: pop(): dictionary is empty
|
||||||
>>>
|
>>>
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
(Patch contributed by Raymond Hettinger.)
|
There's also a new class method,
|
||||||
|
\method{dict.fromkeys(\var{iterable}, \var{value})}, that
|
||||||
|
creates a dictionary with keys taken from the supplied iterator
|
||||||
|
\var{iterable} and all values set to \var{value}, defaulting to
|
||||||
|
\code{None}.
|
||||||
|
|
||||||
|
(Patches contributed by Raymond Hettinger.)
|
||||||
|
|
||||||
\item The \keyword{assert} statement no longer checks the \code{__debug__}
|
\item The \keyword{assert} statement no longer checks the \code{__debug__}
|
||||||
flag, so you can no longer disable assertions by assigning to \code{__debug__}.
|
flag, so you can no longer disable assertions by assigning to \code{__debug__}.
|
||||||
|
@ -1283,29 +1289,28 @@ stamps, or if they use the tuple API. If used, the feature should be
|
||||||
activated on an application level instead of trying to enable it on a
|
activated on an application level instead of trying to enable it on a
|
||||||
per-use basis.
|
per-use basis.
|
||||||
|
|
||||||
\item Calling Tcl methods through \module{_tkinter} now does not
|
\item Calling Tcl methods through \module{_tkinter} no longer
|
||||||
always return strings anymore. Instead, if Tcl returns other objects,
|
returns only strings. Instead, if Tcl returns other objects those
|
||||||
those objects are converted to their Python equivalent, if one exists,
|
objects are converted to their Python equivalent, if one exists, or
|
||||||
or wrapped with a \class{_tkinter.Tcl_Obj} object if no Python
|
wrapped with a \class{_tkinter.Tcl_Obj} object if no Python equivalent
|
||||||
equivalent exists. This behaviour can be controlled through the
|
exists. This behaviour can be controlled through the
|
||||||
\method{wantobjects} method of \class{tkapp} objects.
|
\method{wantobjects()} method of \class{tkapp} objects.
|
||||||
|
|
||||||
When using _tkinter through Tkinter.py (i.e. for most _tkinter
|
When using \module{_tkinter} through the \module{Tkinter} module (as
|
||||||
applications), this feature is always activated. It should not cause
|
most Tkinter applications will), this feature is always activated. It
|
||||||
compatibility problems, since Tkinter would always convert string
|
should not cause compatibility problems, since Tkinter would always
|
||||||
results to Python types were possible.
|
convert string results to Python types where possible.
|
||||||
|
|
||||||
If any incompatibilities are found, the old behaviour can be restored
|
If any incompatibilities are found, the old behaviour can be restored
|
||||||
by invoking
|
by setting the \member{wantobjects} variable in the \module{Tkinter}
|
||||||
|
module to false before creating the first \class{tkapp} object.
|
||||||
|
|
||||||
\begin{verbatim}
|
\begin{verbatim}
|
||||||
import Tkinter
|
import Tkinter
|
||||||
Tkinter.wantobjects = 0
|
Tkinter.wantobjects = 0
|
||||||
\end{verbatim}
|
\end{verbatim}
|
||||||
|
|
||||||
before creating the first \class{tkapp} object.
|
Please report any breakage caused by this change as a bug.
|
||||||
|
|
||||||
Please report any such breakage as a bug.
|
|
||||||
|
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
|
@ -1652,6 +1657,12 @@ if \var{X} is more than one character long.
|
||||||
integer instead of raising an \exception{OverflowError} when a string
|
integer instead of raising an \exception{OverflowError} when a string
|
||||||
or floating-point number is too large to fit into an integer.
|
or floating-point number is too large to fit into an integer.
|
||||||
|
|
||||||
|
\item Calling Tcl methods through \module{_tkinter} no longer
|
||||||
|
returns only strings. Instead, if Tcl returns other objects those
|
||||||
|
objects are converted to their Python equivalent, if one exists, or
|
||||||
|
wrapped with a \class{_tkinter.Tcl_Obj} object if no Python equivalent
|
||||||
|
exists.
|
||||||
|
|
||||||
\item You can no longer disable assertions by assigning to \code{__debug__}.
|
\item You can no longer disable assertions by assigning to \code{__debug__}.
|
||||||
|
|
||||||
\item The Distutils \function{setup()} function has gained various new
|
\item The Distutils \function{setup()} function has gained various new
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue