Commit d4462300 authored by Raymond Hettinger's avatar Raymond Hettinger

Nits from a review of the documentation update.

parent 72452650
...@@ -1063,7 +1063,7 @@ It's a function ...@@ -1063,7 +1063,7 @@ It's a function
\versionchanged[Formerly, \function{zip()} required at least one argument \versionchanged[Formerly, \function{zip()} required at least one argument
and \code{zip()} raised a \exception{TypeError} instead of returning and \code{zip()} raised a \exception{TypeError} instead of returning
\code{[]}]{2.4} an empty list.]{2.4}
\end{funcdesc} \end{funcdesc}
......
...@@ -91,7 +91,7 @@ the following operations: ...@@ -91,7 +91,7 @@ the following operations:
{new set with a shallow copy of \var{s}} {new set with a shallow copy of \var{s}}
\end{tableiii} \end{tableiii}
Note, this non-operator versions of \method{union()}, Note, the non-operator versions of \method{union()},
\method{intersection()}, \method{difference()}, and \method{intersection()}, \method{difference()}, and
\method{symmetric_difference()} will accept any iterable as an argument. \method{symmetric_difference()} will accept any iterable as an argument.
In contrast, their operator based counterparts require their arguments to In contrast, their operator based counterparts require their arguments to
...@@ -158,10 +158,7 @@ but not found in \class{ImmutableSet}: ...@@ -158,10 +158,7 @@ but not found in \class{ImmutableSet}:
{remove all elements from set \var{s}} {remove all elements from set \var{s}}
\end{tableiii} \end{tableiii}
\versionchanged[Earlier versions had an \method{update()} method; use Note, the non-operator versions of \method{union_update()},
\method{union_update()} instead]{2.3.1}
Note, this non-operator versions of \method{union_update()},
\method{intersection_update()}, \method{difference_update()}, and \method{intersection_update()}, \method{difference_update()}, and
\method{symmetric_difference_update()} will accept any iterable as \method{symmetric_difference_update()} will accept any iterable as
an argument. an argument.
......
...@@ -2161,11 +2161,11 @@ pattern, list comprehensions can compactly specify the key-value list. ...@@ -2161,11 +2161,11 @@ pattern, list comprehensions can compactly specify the key-value list.
\section{Looping Techniques \label{loopidioms}} \section{Looping Techniques \label{loopidioms}}
When looping through dictionaries, the key and corresponding value can When looping through dictionaries, the key and corresponding value can
be retrieved at the same time using the \method{items()} method. be retrieved at the same time using the \method{iteritems()} method.
\begin{verbatim} \begin{verbatim}
>>> knights = {'gallahad': 'the pure', 'robin': 'the brave'} >>> knights = {'gallahad': 'the pure', 'robin': 'the brave'}
>>> for k, v in knights.items(): >>> for k, v in knights.iteritems():
... print k, v ... print k, v
... ...
gallahad the pure gallahad the pure
...@@ -3957,7 +3957,7 @@ list, and the function object is called with this new argument list. ...@@ -3957,7 +3957,7 @@ list, and the function object is called with this new argument list.
\section{Random Remarks \label{remarks}} \section{Random Remarks \label{remarks}}
[These should perhaps be placed more carefully...] % [These should perhaps be placed more carefully...]
Data attributes override method attributes with the same name; to Data attributes override method attributes with the same name; to
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
\tableofcontents \tableofcontents
This article explains the new features in Python 2.4. No release date This article explains the new features in Python 2.4. No release date
for Python 2.4 has been set; expect that this will happen in 2004. for Python 2.4 has been set; expect that this will happen mid-2004.
While Python 2.3 was primarily a library development release, Python While Python 2.3 was primarily a library development release, Python
2.4 may extend the core language and interpreter in 2.4 may extend the core language and interpreter in
...@@ -42,6 +42,7 @@ False ...@@ -42,6 +42,7 @@ False
set(['a', 'r', 'b', 'c', 'd']) set(['a', 'r', 'b', 'c', 'd'])
>>> ''.join(a) # convert back into a string >>> ''.join(a) # convert back into a string
'arbcd' 'arbcd'
>>> b = set('alacazam') # form a second set >>> b = set('alacazam') # form a second set
>>> a - b # letters in a but not in b >>> a - b # letters in a but not in b
set(['r', 'd', 'b']) set(['r', 'd', 'b'])
...@@ -51,6 +52,7 @@ set(['a', 'c', 'r', 'd', 'b', 'm', 'z', 'l']) ...@@ -51,6 +52,7 @@ set(['a', 'c', 'r', 'd', 'b', 'm', 'z', 'l'])
set(['a', 'c']) set(['a', 'c'])
>>> a ^ b # letters in a or b but not both >>> a ^ b # letters in a or b but not both
set(['r', 'd', 'b', 'm', 'z', 'l']) set(['r', 'd', 'b', 'm', 'z', 'l'])
>>> a.add('z') # add a new element >>> a.add('z') # add a new element
>>> a.update('wxy') # add multiple new elements >>> a.update('wxy') # add multiple new elements
>>> a >>> a
...@@ -115,6 +117,11 @@ Here are all of the changes that Python 2.4 makes to the core Python ...@@ -115,6 +117,11 @@ Here are all of the changes that Python 2.4 makes to the core Python
language. language.
\begin{itemize} \begin{itemize}
\item The string methods, \method{ljust()}, \method{rjust()}, and
\method{center()} now take a optional argument for specifying a
fill character other than a space.
\item The \method{sort()} method of lists gained three keyword \item The \method{sort()} method of lists gained three keyword
arguments, \var{cmp}, \var{key}, and \var{reverse}. These arguments arguments, \var{cmp}, \var{key}, and \var{reverse}. These arguments
make some common usages of \method{sort()} simpler. All are optional. make some common usages of \method{sort()} simpler. All are optional.
...@@ -185,10 +192,12 @@ use in expressions. The differences are: ...@@ -185,10 +192,12 @@ use in expressions. The differences are:
[11, 12, 13, 14, 15, 16, 17, 18, 19] [11, 12, 13, 14, 15, 16, 17, 18, 19]
>>> L = [9,7,8,3,2,4,1,6,5] # original is left unchanged >>> L = [9,7,8,3,2,4,1,6,5] # original is left unchanged
[9,7,8,3,2,4,1,6,5] [9,7,8,3,2,4,1,6,5]
>>> list.sorted('Monte Python') # any iterable may be an input >>> list.sorted('Monte Python') # any iterable may be an input
[' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y'] [' ', 'M', 'P', 'e', 'h', 'n', 'n', 'o', 'o', 't', 't', 'y']
>>> # List the contents of a dict sorted by key values
>>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5) >>> colormap = dict(red=1, blue=2, green=3, black=4, yellow=5)
>>> # Lists the contents of the dict sorted by key values
>>> for k, v in list.sorted(colormap.iteritems()): >>> for k, v in list.sorted(colormap.iteritems()):
... print k, v ... print k, v
... ...
...@@ -202,7 +211,7 @@ yellow 5 ...@@ -202,7 +211,7 @@ yellow 5
\item The \function{zip()} built-in function and \function{itertools.izip()} \item The \function{zip()} built-in function and \function{itertools.izip()}
now return an empty list instead of raising a \exception{TypeError} now returns an empty list instead of raising a \exception{TypeError}
exception if called with no arguments. This makes the functions more exception if called with no arguments. This makes the functions more
suitable for use with variable length argument lists: suitable for use with variable length argument lists:
...@@ -297,6 +306,12 @@ Changes to Python's build process and to the C API include: ...@@ -297,6 +306,12 @@ Changes to Python's build process and to the C API include:
objN)}, constructs tuples from a variable length argument list of objN)}, constructs tuples from a variable length argument list of
Python objects. Python objects.
\item A new function, \function{PyDict_Contains(d, k)}, implements
fast dictionary lookups without masking exceptions raised during
the loop-up process (compare with \function{PySequence_Contains()}
which is slower or \function{PyMapping_HasKey()} which clears all
exceptions).
\end{itemize} \end{itemize}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment