11\documentclass {howto }
22
33\title {What's New in Python 2.0}
4- \release {0.04 }
4+ \release {0.05 }
55\author {A.M. Kuchling and Moshe Zadka}
66\authoraddress {
\email {
[email protected] },
\email {
[email protected] } }
77\begin {document }
@@ -81,8 +81,8 @@ \section{Unicode}
8181
8282\item \code {ord(\var {u})}, where \var {u} is a 1-character regular or Unicode string, returns the number of the character as an integer.
8383
84- \item \code {unicode(\var {string}, \optional {\var {encoding}, }
85- \optional {\var {errors}} ) } creates a Unicode string from an 8-bit
84+ \item \code {unicode(\var {string} \optional {, \var {encoding}}
85+ \optional {, \var {errors}} ) } creates a Unicode string from an 8-bit
8686string. \code {encoding} is a string naming the encoding to use.
8787The \code {errors} parameter specifies the treatment of characters that
8888are invalid for the current encoding; passing \code {'strict'} as the
@@ -151,7 +151,7 @@ \section{Unicode}
151151The following code would then read UTF-8 input from the file:
152152
153153\begin {verbatim }
154- input = UTF8_streamread ( open( '/tmp/output', 'rb') )
154+ input = UTF8_streamreader ( open( '/tmp/output', 'rb') )
155155print repr(input.read())
156156input.close()
157157\end {verbatim }
@@ -272,11 +272,10 @@ \section{List Comprehensions}
272272\section {Augmented Assignment }
273273
274274Augmented assignment operators, another long-requested feature, have
275- been added to Python 2.0. Augmented assignment operators include
276- \code {+=}, \code {-=}, \code {*=}, and so forth. For example, the
277- statement \code {a += 2} increments the value of the variable \code {a}
278- by 2, equivalent to the slightly lengthier
279- \code {a = a + 2}.
275+ been added to Python 2.0. Augmented assignment operators include
276+ \code {+=}, \code {-=}, \code {*=}, and so forth. For example, the
277+ statement \code {a += 2} increments the value of the variable
278+ \code {a} by 2, equivalent to the slightly lengthier \code {a = a + 2}.
280279
281280The full list of supported assignment operators is \code {+=},
282281\code {-=}, \code {*=}, \code {/=}, \code {\% =}, \code {**=}, \code {\& =},
@@ -312,7 +311,7 @@ \section{Augmented Assignment}
312311\section {String Methods }
313312
314313Until now string-manipulation functionality was in the \module {string}
315- Python module, which was usually a front-end for the \module {strop}
314+ module, which was usually a front-end for the \module {strop}
316315module written in C. The addition of Unicode posed a difficulty for
317316the \module {strop} module, because the functions would all need to be
318317rewritten in order to accept either 8-bit or Unicode strings. For
@@ -445,12 +444,12 @@ \subsection{Minor Language Changes}
445444\end {verbatim }
446445
447446The \keyword {print} statement can now have its output directed to a
448- file-like object by following the \keyword {print} with \code {>>
449- \var {fileobj}} , similar to the redirection operator in Unix shells.
447+ file-like object by following the \keyword {print} with
448+ \verb | >> file | , similar to the redirection operator in Unix shells.
450449Previously you'd either have to use the \method {write()} method of the
451450file-like object, which lacks the convenience and simplicity of
452- \keyword {print}, or you could assign a new value to \code {sys.stdout}
453- and then restore the old value. For sending output to standard error,
451+ \keyword {print}, or you could assign a new value to
452+ \code {sys.stdout} and then restore the old value. For sending output to standard error,
454453it's much easier to write this:
455454
456455\begin {verbatim }
@@ -535,9 +534,10 @@ \subsection{Changes to Built-in Functions}
535534added. \function {zip()} returns a list of tuples where each tuple
536535contains the i-th element from each of the argument sequences. The
537536difference between \function {zip()} and \code {map(None, \var {seq1},
538- \var {seq2})} is that \function {map()} raises an error if the sequences
539- aren't all of the same length, while \function {zip()} truncates the
540- returned list to the length of the shortest argument sequence.
537+ \var {seq2})} is that \function {map()} pads the sequences with
538+ \code {None} if the sequences aren't all of the same length, while
539+ \function {zip()} truncates the returned list to the length of the
540+ shortest argument sequence.
541541
542542The \function {int()} and \function {long()} functions now accept an
543543optional `` base'' parameter when the first argument is a string.
@@ -551,7 +551,7 @@ \subsection{Changes to Built-in Functions}
551551\var {serial})} For example, in a hypothetical 2.0.1beta1,
552552\code {sys.version_info} would be \code {(2, 0, 1, 'beta' , 1)}.
553553\var {level} is a string such as \code {"alpha"}, \code {"beta"}, or
554- \code {""} for a final release.
554+ \code {"final "} for a final release.
555555
556556Dictionaries have an odd new method, \method {setdefault(\var {key},
557557\var {default})}, which behaves similarly to the existing
@@ -609,7 +609,7 @@ \section{Porting to 2.0}
609609because the documentation actually used the erroneous multiple
610610argument form, many people wrote code which would break with the
611611stricter checking. GvR backed out the changes in the face of public
612- reaction, so for the\module {socket} module, the documentation was
612+ reaction, so for the \module {socket} module, the documentation was
613613fixed and the multiple argument form is simply marked as deprecated;
614614it \emph {will } be tightened up again in a future Python version.
615615
@@ -631,16 +631,15 @@ \section{Porting to 2.0}
631631\function {repr()} still includes it. The 'L' annoyed many people who
632632wanted to print long integers that looked just like regular integers,
633633since they had to go out of their way to chop off the character. This
634- is no longer a problem in 2.0, but code which assumes the 'L' is
635- there, and does \code {str(longval)[:-1]} will now lose the final
636- digit.
634+ is no longer a problem in 2.0, but code which does \code {str(longval)[:-1]} and assumes the 'L' is there, will now lose
635+ the final digit.
637636
638637Taking the \function {repr()} of a float now uses a different
639638formatting precision than \function {str()}. \function {repr()} uses
640639\code {\% .17g} format string for C's \function {sprintf()}, while
641640\function {str()} uses \code {\% .12g} as before. The effect is that
642641\function {repr()} may occasionally show more decimal places than
643- \function {str()}, for numbers
642+ \function {str()}, for certain numbers.
644643For example, the number 8.1 can't be represented exactly in binary, so
645644\code {repr(8.1)} is \code {'8.0999999999999996'}, while str(8.1) is
646645\code {'8.1'}.
@@ -727,7 +726,7 @@ \section{Distutils: Making Modules Easy to Install}
727726Before Python 2.0, installing modules was a tedious affair -- there
728727was no way to figure out automatically where Python is installed, or
729728what compiler options to use for extension modules. Software authors
730- had to go through an ardous ritual of editing Makefiles and
729+ had to go through an arduous ritual of editing Makefiles and
731730configuration files, which only really work on Unix and leave Windows
732731and MacOS unsupported. Software users faced wildly differing
733732installation instructions
@@ -835,8 +834,8 @@ \section{Module changes}
835834The \module {Tkinter} module now supports Tcl/Tk version 8.1, 8.2, or
8368358.3, and support for the older 7.x versions has been dropped. The
837836Tkinter module now supports displaying Unicode strings in Tk widgets.
838- Also, Fredrik Lundh contributed an optimization which make operations
839- like \code {create_line} and \code {create_polygon} are much faster,
837+ Also, Fredrik Lundh contributed an optimization which makes operations
838+ like \code {create_line} and \code {create_polygon} much faster,
840839especially when using lots of coordinates.
841840
842841The \module {curses} module has been greatly extended, starting from
@@ -895,12 +894,12 @@ \section{New modules}
895894
896895\item {\module {robotparser}:} Parse a \file {robots.txt} file, which is
897896used for writing Web spiders that politely avoid certain areas of a
898- Web site. The parser accepts the contents of a \file {robots.txt} file
897+ Web site. The parser accepts the contents of a \file {robots.txt} file,
899898builds a set of rules from it, and can then answer questions about
900899the fetchability of a given URL. (Contributed by Skip Montanaro.)
901900
902901\item {\module {tabnanny}:} A module/script to
903- checks Python source code for ambiguous indentation.
902+ check Python source code for ambiguous indentation.
904903(Contributed by Tim Peters.)
905904
906905\item {\module {UserString}:} A base class useful for deriving objects that behave like strings.
@@ -992,7 +991,8 @@ \section{Deleted and Deprecated Modules}
992991\section {Acknowledgements }
993992
994993The authors would like to thank the following people for offering
995- suggestions on drafts of this article: Fredrik Lundh, Skip
996- Montanaro, Vladimir Marangozov, Guido van Rossum, Neil Schemenauer.
994+ suggestions on drafts of this article: Mark Hammond, Fredrik Lundh,
995+ Detlef Lannert, Skip Montanaro, Vladimir Marangozov, Guido van Rossum,
996+ and Neil Schemenauer.
997997
998998\end {document }
0 commit comments