Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 1 | \documentclass{howto} |
| 2 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 3 | \title{What's New in Python 2.0} |
| 4 | \release{0.04} |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 5 | \author{A.M. Kuchling and Moshe Zadka} |
| 6 | \authoraddress{\email{amk1@bigfoot.com}, \email{moshez@math.huji.ac.il} } |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 7 | \begin{document} |
| 8 | \maketitle\tableofcontents |
| 9 | |
| 10 | \section{Introduction} |
| 11 | |
Andrew M. Kuchling | 69db0e4 | 2000-06-28 02:16:00 +0000 | [diff] [blame] | 12 | {\large This is a draft document; please report inaccuracies and |
| 13 | omissions to the authors. This document should not be treated as |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 14 | definitive; features described here might be removed or changed during |
| 15 | the beta cycle before the final release of Python 2.0. |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 16 | } |
| 17 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 18 | A new release of Python, version 2.0, will be released some time this |
Andrew M. Kuchling | 70ba382 | 2000-07-01 00:13:30 +0000 | [diff] [blame] | 19 | summer. Beta versions are already available from |
| 20 | \url{http://www.pythonlabs.com/tech/python2.html}. This article |
| 21 | covers the exciting new features in 2.0, highlights some other useful |
| 22 | changes, and points out a few incompatible changes that may require |
| 23 | rewriting code. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 24 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 25 | Python's development never completely stops between releases, and a |
| 26 | steady flow of bug fixes and improvements are always being submitted. |
| 27 | A host of minor fixes, a few optimizations, additional docstrings, and |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 28 | better error messages went into 2.0; to list them all would be |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 29 | impossible, but they're certainly significant. Consult the |
| 30 | publicly-available CVS logs if you want to see the full list. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 31 | |
| 32 | % ====================================================================== |
| 33 | \section{Unicode} |
| 34 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 35 | The largest new feature in Python 2.0 is a new fundamental data type: |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 36 | Unicode strings. Unicode uses 16-bit numbers to represent characters |
| 37 | instead of the 8-bit number used by ASCII, meaning that 65,536 |
| 38 | distinct characters can be supported. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 39 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 40 | The final interface for Unicode support was arrived at through |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 41 | countless often-stormy discussions on the python-dev mailing list, and |
Andrew M. Kuchling | 62cdd96 | 2000-06-30 12:46:41 +0000 | [diff] [blame] | 42 | mostly implemented by Marc-Andr\'e Lemburg, based on a Unicode string |
| 43 | type implementation by Fredrik Lundh. A detailed explanation of the |
| 44 | interface is in the file \file{Misc/unicode.txt} in the Python source |
| 45 | distribution; it's also available on the Web at |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 46 | \url{http://starship.python.net/crew/lemburg/unicode-proposal.txt}. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 47 | This article will simply cover the most significant points from the |
| 48 | full interface. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 49 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 50 | In Python source code, Unicode strings are written as |
| 51 | \code{u"string"}. Arbitrary Unicode characters can be written using a |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 52 | new escape sequence, \code{\e u\var{HHHH}}, where \var{HHHH} is a |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 53 | 4-digit hexadecimal number from 0000 to FFFF. The existing |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 54 | \code{\e x\var{HHHH}} escape sequence can also be used, and octal |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 55 | escapes can be used for characters up to U+01FF, which is represented |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 56 | by \code{\e 777}. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 57 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 58 | Unicode strings, just like regular strings, are an immutable sequence |
Andrew M. Kuchling | 662d76e | 2000-06-25 14:32:48 +0000 | [diff] [blame] | 59 | type. They can be indexed and sliced, but not modified in place. |
Andrew M. Kuchling | 62cdd96 | 2000-06-30 12:46:41 +0000 | [diff] [blame] | 60 | Unicode strings have an \method{encode( \optional{encoding} )} method |
Andrew M. Kuchling | 662d76e | 2000-06-25 14:32:48 +0000 | [diff] [blame] | 61 | that returns an 8-bit string in the desired encoding. Encodings are |
| 62 | named by strings, such as \code{'ascii'}, \code{'utf-8'}, |
| 63 | \code{'iso-8859-1'}, or whatever. A codec API is defined for |
| 64 | implementing and registering new encodings that are then available |
| 65 | throughout a Python program. If an encoding isn't specified, the |
| 66 | default encoding is usually 7-bit ASCII, though it can be changed for |
| 67 | your Python installation by calling the |
Andrew M. Kuchling | c0328f0 | 2000-06-10 15:11:20 +0000 | [diff] [blame] | 68 | \function{sys.setdefaultencoding(\var{encoding})} function in a |
Andrew M. Kuchling | 69db0e4 | 2000-06-28 02:16:00 +0000 | [diff] [blame] | 69 | customised version of \file{site.py}. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 70 | |
| 71 | Combining 8-bit and Unicode strings always coerces to Unicode, using |
| 72 | the default ASCII encoding; the result of \code{'a' + u'bc'} is |
Andrew M. Kuchling | 7f6270d | 2000-06-09 02:48:18 +0000 | [diff] [blame] | 73 | \code{u'abc'}. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 74 | |
| 75 | New built-in functions have been added, and existing built-ins |
| 76 | modified to support Unicode: |
| 77 | |
| 78 | \begin{itemize} |
| 79 | \item \code{unichr(\var{ch})} returns a Unicode string 1 character |
| 80 | long, containing the character \var{ch}. |
| 81 | |
| 82 | \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. |
| 83 | |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 84 | \item \code{unicode(\var{string}, \optional{\var{encoding},} |
| 85 | \optional{\var{errors}} ) } creates a Unicode string from an 8-bit |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 86 | string. \code{encoding} is a string naming the encoding to use. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 87 | The \code{errors} parameter specifies the treatment of characters that |
| 88 | are invalid for the current encoding; passing \code{'strict'} as the |
| 89 | value causes an exception to be raised on any encoding error, while |
| 90 | \code{'ignore'} causes errors to be silently ignored and |
| 91 | \code{'replace'} uses U+FFFD, the official replacement character, in |
| 92 | case of any problems. |
| 93 | |
| 94 | \end{itemize} |
| 95 | |
| 96 | A new module, \module{unicodedata}, provides an interface to Unicode |
| 97 | character properties. For example, \code{unicodedata.category(u'A')} |
| 98 | returns the 2-character string 'Lu', the 'L' denoting it's a letter, |
| 99 | and 'u' meaning that it's uppercase. |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 100 | \code{u.bidirectional(u'\e x0660')} returns 'AN', meaning that U+0660 is |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 101 | an Arabic number. |
| 102 | |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 103 | The \module{codecs} module contains functions to look up existing encodings |
| 104 | and register new ones. Unless you want to implement a |
| 105 | new encoding, you'll most often use the |
| 106 | \function{codecs.lookup(\var{encoding})} function, which returns a |
| 107 | 4-element tuple: \code{(\var{encode_func}, |
| 108 | \var{decode_func}, \var{stream_reader}, \var{stream_writer})}. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 109 | |
| 110 | \begin{itemize} |
| 111 | \item \var{encode_func} is a function that takes a Unicode string, and |
| 112 | returns a 2-tuple \code{(\var{string}, \var{length})}. \var{string} |
| 113 | is an 8-bit string containing a portion (perhaps all) of the Unicode |
Andrew M. Kuchling | 2d2dc9f | 2000-08-17 00:27:06 +0000 | [diff] [blame] | 114 | string converted into the given encoding, and \var{length} tells you |
| 115 | how much of the Unicode string was converted. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 116 | |
| 117 | \item \var{decode_func} is the mirror of \var{encode_func}, |
| 118 | taking a Unicode string and |
| 119 | returns a 2-tuple \code{(\var{ustring}, \var{length})} containing a Unicode string |
| 120 | and \var{length} telling you how much of the string was consumed. |
| 121 | |
| 122 | \item \var{stream_reader} is a class that supports decoding input from |
| 123 | a stream. \var{stream_reader(\var{file_obj})} returns an object that |
| 124 | supports the \method{read()}, \method{readline()}, and |
| 125 | \method{readlines()} methods. These methods will all translate from |
| 126 | the given encoding and return Unicode strings. |
| 127 | |
| 128 | \item \var{stream_writer}, similarly, is a class that supports |
| 129 | encoding output to a stream. \var{stream_writer(\var{file_obj})} |
Andrew M. Kuchling | 69db0e4 | 2000-06-28 02:16:00 +0000 | [diff] [blame] | 130 | returns an object that supports the \method{write()} and |
| 131 | \method{writelines()} methods. These methods expect Unicode strings, |
| 132 | translating them to the given encoding on output. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 133 | \end{itemize} |
| 134 | |
| 135 | For example, the following code writes a Unicode string into a file, |
| 136 | encoding it as UTF-8: |
| 137 | |
| 138 | \begin{verbatim} |
| 139 | import codecs |
| 140 | |
| 141 | unistr = u'\u0660\u2000ab ...' |
| 142 | |
| 143 | (UTF8_encode, UTF8_decode, |
| 144 | UTF8_streamreader, UTF8_streamwriter) = codecs.lookup('UTF-8') |
| 145 | |
| 146 | output = UTF8_streamwriter( open( '/tmp/output', 'wb') ) |
| 147 | output.write( unistr ) |
| 148 | output.close() |
| 149 | \end{verbatim} |
| 150 | |
| 151 | The following code would then read UTF-8 input from the file: |
| 152 | |
| 153 | \begin{verbatim} |
| 154 | input = UTF8_streamread( open( '/tmp/output', 'rb') ) |
| 155 | print repr(input.read()) |
| 156 | input.close() |
| 157 | \end{verbatim} |
| 158 | |
| 159 | Unicode-aware regular expressions are available through the |
| 160 | \module{re} module, which has a new underlying implementation called |
| 161 | SRE written by Fredrik Lundh of Secret Labs AB. |
| 162 | |
Andrew M. Kuchling | c0328f0 | 2000-06-10 15:11:20 +0000 | [diff] [blame] | 163 | A \code{-U} command line option was added which causes the Python |
| 164 | compiler to interpret all string literals as Unicode string literals. |
| 165 | This is intended to be used in testing and future-proofing your Python |
| 166 | code, since some future version of Python may drop support for 8-bit |
| 167 | strings and provide only Unicode strings. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 168 | |
| 169 | % ====================================================================== |
Andrew M. Kuchling | 2d2dc9f | 2000-08-17 00:27:06 +0000 | [diff] [blame] | 170 | \section{List Comprehensions} |
| 171 | |
| 172 | Lists are a workhorse data type in Python, and many programs |
| 173 | manipulate a list at some point. Two common operations on lists are |
| 174 | to loop over them, and either pick out the elements that meet a |
| 175 | certain criterion, or apply some function to each element. For |
| 176 | example, given a list of strings, you might want to pull out all the |
| 177 | strings containing a given substring, or strip off trailing whitespace |
| 178 | from each line. |
| 179 | |
| 180 | The existing \function{map()} and \function{filter()} functions can be |
| 181 | used for this purpose, but they require a function as one of their |
| 182 | arguments. This is fine if there's an existing built-in function that |
| 183 | can be passed directly, but if there isn't, you have to create a |
| 184 | little function to do the required work, and Python's scoping rules |
| 185 | make the result ugly if the little function needs additional |
| 186 | information. Take the first example in the previous paragraph, |
| 187 | finding all the strings in the list containing a given substring. You |
| 188 | could write the following to do it: |
| 189 | |
| 190 | \begin{verbatim} |
| 191 | # Given the list L, make a list of all strings |
| 192 | # containing the substring S. |
| 193 | sublist = filter( lambda s, substring=S: |
| 194 | string.find(s, substring) != -1, |
| 195 | L) |
| 196 | \end{verbatim} |
| 197 | |
| 198 | Because of Python's scoping rules, a default argument is used so that |
| 199 | the anonymous function created by the \keyword{lambda} statement knows |
| 200 | what substring is being searched for. List comprehensions make this |
| 201 | cleaner: |
| 202 | |
| 203 | \begin{verbatim} |
| 204 | sublist = [ s for s in L if string.find(s, S) != -1 ] |
| 205 | \end{verbatim} |
| 206 | |
| 207 | List comprehensions have the form: |
| 208 | |
| 209 | \begin{verbatim} |
| 210 | [ expression for expr in sequence1 |
| 211 | for expr2 in sequence2 ... |
| 212 | for exprN in sequenceN |
| 213 | if condition |
| 214 | \end{verbatim} |
| 215 | |
| 216 | The \keyword{for}...\keyword{in} clauses contain the sequences to be |
| 217 | iterated over. The sequences do not have to be the same length, |
| 218 | because they are \emph{not} iterated over in parallel, but |
| 219 | from left to right; this is explained more clearly in the following |
| 220 | paragraphs. The elements of the generated list will be the successive |
| 221 | values of \var{expression}. The final \keyword{if} clause is |
| 222 | optional; if present, \var{expression} is only evaluated and added to |
| 223 | the result if \var{condition} is true. |
| 224 | |
| 225 | To make the semantics very clear, a list comprehension is equivalent |
| 226 | to the following Python code: |
| 227 | |
| 228 | \begin{verbatim} |
| 229 | for expr1 in sequence1: |
| 230 | for expr2 in sequence2: |
| 231 | ... |
| 232 | for exprN in sequenceN: |
| 233 | if (condition): |
| 234 | # Append the value of |
| 235 | # the expression to the |
| 236 | # resulting list. |
| 237 | \end{verbatim} |
| 238 | |
| 239 | This means that when there are \keyword{for}...\keyword{in} clauses, |
| 240 | the resulting list will be equal to the product of the lengths of all |
| 241 | the sequences. If you have two lists of length 3, the output list is |
| 242 | 9 elements long: |
| 243 | |
| 244 | \begin{verbatim} |
| 245 | seq1 = 'abc' |
| 246 | seq2 = (1,2,3) |
| 247 | >>> [ (x,y) for x in seq1 for y in seq2] |
| 248 | [('a', 1), ('a', 2), ('a', 3), ('b', 1), ('b', 2), ('b', 3), ('c', 1), |
| 249 | ('c', 2), ('c', 3)] |
| 250 | \end{verbatim} |
| 251 | |
| 252 | To avoid introducing an ambiguity into Python's grammar, if |
| 253 | \var{expression} is creating a tuple, it must be surrounded with |
| 254 | parentheses. The first list comprehension below is a syntax error, |
| 255 | while the second one is correct: |
| 256 | |
| 257 | \begin{verbatim} |
| 258 | # Syntax error |
| 259 | [ x,y for x in seq1 for y in seq2] |
| 260 | # Correct |
| 261 | [ (x,y) for x in seq1 for y in seq2] |
| 262 | \end{verbatim} |
| 263 | |
Andrew M. Kuchling | 2d2dc9f | 2000-08-17 00:27:06 +0000 | [diff] [blame] | 264 | The idea of list comprehensions originally comes from the functional |
| 265 | programming language Haskell (\url{http://www.haskell.org}). Greg |
| 266 | Ewing argued most effectively for adding them to Python and wrote the |
| 267 | initial list comprehension patch, which was then discussed for a |
| 268 | seemingly endless time on the python-dev mailing list and kept |
| 269 | up-to-date by Skip Montanaro. |
| 270 | |
Andrew M. Kuchling | 2d2dc9f | 2000-08-17 00:27:06 +0000 | [diff] [blame] | 271 | % ====================================================================== |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 272 | \section{Augmented Assignment} |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 273 | |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 274 | Augmented 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}. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 280 | |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 281 | The full list of supported assignment operators is \code{+=}, |
| 282 | \code{-=}, \code{*=}, \code{/=}, \code{\%=}, \code{**=}, \code{\&=}, |
| 283 | \code{|=}, \code{^=}, \code{>>=}, and \code{<<=}. Python classes can |
| 284 | override the augmented assignment operators by defining methods named |
| 285 | \method{__iadd__}, \method{__isub__}, etc. For example, the following |
| 286 | \class{Number} class stores a number and supports using += to create a |
| 287 | new instance with an incremented value. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 288 | |
| 289 | \begin{verbatim} |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 290 | class Number: |
| 291 | def __init__(self, value): |
| 292 | self.value = value |
| 293 | def __iadd__(self, increment): |
| 294 | return Number( self.value + increment) |
| 295 | |
| 296 | n = Number(5) |
| 297 | n += 3 |
| 298 | print n.value |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 299 | \end{verbatim} |
| 300 | |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 301 | The \method{__iadd__} special method is called with the value of the |
| 302 | increment, and should return a new instance with an appropriately |
| 303 | modified value; this return value is bound as the new value of the |
| 304 | variable on the left-hand side. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 305 | |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 306 | Augmented assignment operators were first introduced in the C |
| 307 | programming language, and most C-derived languages, such as |
| 308 | \program{awk}, C++, Java, Perl, and PHP also support them. The augmented |
| 309 | assignment patch was implemented by Thomas Wouters. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 310 | |
| 311 | % ====================================================================== |
| 312 | \section{String Methods} |
| 313 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 314 | Until now string-manipulation functionality was in the \module{string} |
| 315 | Python module, which was usually a front-end for the \module{strop} |
| 316 | module written in C. The addition of Unicode posed a difficulty for |
| 317 | the \module{strop} module, because the functions would all need to be |
| 318 | rewritten in order to accept either 8-bit or Unicode strings. For |
| 319 | functions such as \function{string.replace()}, which takes 3 string |
| 320 | arguments, that means eight possible permutations, and correspondingly |
| 321 | complicated code. |
| 322 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 323 | Instead, Python 2.0 pushes the problem onto the string type, making |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 324 | string manipulation functionality available through methods on both |
| 325 | 8-bit strings and Unicode strings. |
| 326 | |
| 327 | \begin{verbatim} |
| 328 | >>> 'andrew'.capitalize() |
| 329 | 'Andrew' |
| 330 | >>> 'hostname'.replace('os', 'linux') |
| 331 | 'hlinuxtname' |
| 332 | >>> 'moshe'.find('sh') |
| 333 | 2 |
| 334 | \end{verbatim} |
| 335 | |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 336 | One thing that hasn't changed, a noteworthy April Fools' joke |
| 337 | notwithstanding, is that Python strings are immutable. Thus, the |
| 338 | string methods return new strings, and do not modify the string on |
| 339 | which they operate. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 340 | |
| 341 | The old \module{string} module is still around for backwards |
| 342 | compatibility, but it mostly acts as a front-end to the new string |
| 343 | methods. |
| 344 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 345 | Two methods which have no parallel in pre-2.0 versions, although they |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 346 | did exist in JPython for quite some time, are \method{startswith()} |
| 347 | and \method{endswith}. \code{s.startswith(t)} is equivalent to \code{s[:len(t)] |
| 348 | == t}, while \code{s.endswith(t)} is equivalent to \code{s[-len(t):] == t}. |
| 349 | |
Andrew M. Kuchling | fed4f1e | 2000-07-01 12:33:43 +0000 | [diff] [blame] | 350 | One other method which deserves special mention is \method{join}. The |
| 351 | \method{join} method of a string receives one parameter, a sequence of |
| 352 | strings, and is equivalent to the \function{string.join} function from |
| 353 | the old \module{string} module, with the arguments reversed. In other |
| 354 | words, \code{s.join(seq)} is equivalent to the old |
| 355 | \code{string.join(seq, s)}. |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 356 | |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 357 | % ====================================================================== |
Andrew M. Kuchling | 35e8afb | 2000-07-08 12:06:31 +0000 | [diff] [blame] | 358 | \section{Optional Collection of Cycles} |
| 359 | |
| 360 | The C implementation of Python uses reference counting to implement |
| 361 | garbage collection. Every Python object maintains a count of the |
| 362 | number of references pointing to itself, and adjusts the count as |
| 363 | references are created or destroyed. Once the reference count reaches |
| 364 | zero, the object is no longer accessible, since you need to have a |
| 365 | reference to an object to access it, and if the count is zero, no |
| 366 | references exist any longer. |
| 367 | |
| 368 | Reference counting has some pleasant properties: it's easy to |
| 369 | understand and implement, and the resulting implementation is |
| 370 | portable, fairly fast, and reacts well with other libraries that |
| 371 | implement their own memory handling schemes. The major problem with |
| 372 | reference counting is that it sometimes doesn't realise that objects |
| 373 | are no longer accessible, resulting in a memory leak. This happens |
| 374 | when there are cycles of references. |
| 375 | |
| 376 | Consider the simplest possible cycle, |
| 377 | a class instance which has a reference to itself: |
| 378 | |
| 379 | \begin{verbatim} |
| 380 | instance = SomeClass() |
| 381 | instance.myself = instance |
| 382 | \end{verbatim} |
| 383 | |
| 384 | After the above two lines of code have been executed, the reference |
| 385 | count of \code{instance} is 2; one reference is from the variable |
| 386 | named \samp{'instance'}, and the other is from the \samp{myself} |
| 387 | attribute of the instance. |
| 388 | |
| 389 | If the next line of code is \code{del instance}, what happens? The |
| 390 | reference count of \code{instance} is decreased by 1, so it has a |
| 391 | reference count of 1; the reference in the \samp{myself} attribute |
| 392 | still exists. Yet the instance is no longer accessible through Python |
| 393 | code, and it could be deleted. Several objects can participate in a |
| 394 | cycle if they have references to each other, causing all of the |
| 395 | objects to be leaked. |
| 396 | |
| 397 | An experimental step has been made toward fixing this problem. When |
| 398 | compiling Python, the \verb|--with-cycle-gc| option can be specified. |
| 399 | This causes a cycle detection algorithm to be periodically executed, |
| 400 | which looks for inaccessible cycles and deletes the objects involved. |
| 401 | A new \module{gc} module provides functions to perform a garbage |
| 402 | collection, obtain debugging statistics, and tuning the collector's parameters. |
| 403 | |
| 404 | Why isn't cycle detection enabled by default? Running the cycle detection |
| 405 | algorithm takes some time, and some tuning will be required to |
| 406 | minimize the overhead cost. It's not yet obvious how much performance |
| 407 | is lost, because benchmarking this is tricky and depends crucially |
| 408 | on how often the program creates and destroys objects. |
| 409 | |
| 410 | Several people tackled this problem and contributed to a solution. An |
| 411 | early implementation of the cycle detection approach was written by |
| 412 | Toby Kelsey. The current algorithm was suggested by Eric Tiedemann |
| 413 | during a visit to CNRI, and Guido van Rossum and Neil Schemenauer |
| 414 | wrote two different implementations, which were later integrated by |
| 415 | Neil. Lots of other people offered suggestions along the way; the |
| 416 | March 2000 archives of the python-dev mailing list contain most of the |
| 417 | relevant discussion, especially in the threads titled ``Reference |
| 418 | cycle collection for Python'' and ``Finalization again''. |
| 419 | |
Andrew M. Kuchling | 35e8afb | 2000-07-08 12:06:31 +0000 | [diff] [blame] | 420 | % ====================================================================== |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 421 | \section{Other Core Changes} |
Andrew M. Kuchling | 35e8afb | 2000-07-08 12:06:31 +0000 | [diff] [blame] | 422 | |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 423 | Various minor changes have been made to Python's syntax and built-in |
| 424 | functions. None of the changes are very far-reaching, but they're |
| 425 | handy conveniences. |
| 426 | |
| 427 | \subsection{Minor Language Changes} |
| 428 | |
| 429 | A new syntax makes it more convenient to call a given function |
| 430 | with a tuple of arguments and/or a dictionary of keyword arguments. |
| 431 | In Python 1.5 and earlier, you'd use the \function{apply()} |
| 432 | built-in function: \code{apply(f, \var{args}, \var{kw})} calls the |
| 433 | function \function{f()} with the argument tuple \var{args} and the |
| 434 | keyword arguments in the dictionary \var{kw}. \function{apply()} |
| 435 | is the same in 2.0, but thanks to a patch from |
| 436 | Greg Ewing, \code{f(*\var{args}, **\var{kw})} as a shorter |
| 437 | and clearer way to achieve the same effect. This syntax is |
| 438 | symmetrical with the syntax for defining functions: |
| 439 | |
| 440 | \begin{verbatim} |
| 441 | def f(*args, **kw): |
| 442 | # args is a tuple of positional args, |
| 443 | # kw is a dictionary of keyword args |
| 444 | ... |
| 445 | \end{verbatim} |
| 446 | |
| 447 | The \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. |
| 450 | Previously you'd either have to use the \method{write()} method of the |
| 451 | file-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, |
| 454 | it's much easier to write this: |
| 455 | |
| 456 | \begin{verbatim} |
| 457 | print >> sys.stderr, "Warning: action field not supplied" |
| 458 | \end{verbatim} |
| 459 | |
| 460 | Modules can now be renamed on importing them, using the syntax |
| 461 | \code{import \var{module} as \var{name}} or \code{from \var{module} |
| 462 | import \var{name} as \var{othername}}. The patch was submitted by |
| 463 | Thomas Wouters. |
| 464 | |
| 465 | A new format style is available when using the \code{\%} operator; |
| 466 | '\%r' will insert the \function{repr()} of its argument. This was |
| 467 | also added from symmetry considerations, this time for symmetry with |
| 468 | the existing '\%s' format style, which inserts the \function{str()} of |
| 469 | its argument. For example, \code{'\%r \%s' \% ('abc', 'abc')} returns a |
| 470 | string containing \verb|'abc' abc|. |
| 471 | |
| 472 | Previously there was no way to implement a class that overrode |
| 473 | Python's built-in \keyword{in} operator and implemented a custom |
| 474 | version. \code{\var{obj} in \var{seq}} returns true if \var{obj} is |
| 475 | present in the sequence \var{seq}; Python computes this by simply |
| 476 | trying every index of the sequence until either \var{obj} is found or |
| 477 | an \exception{IndexError} is encountered. Moshe Zadka contributed a |
| 478 | patch which adds a \method{__contains__} magic method for providing a |
| 479 | custom implementation for \keyword{in}. Additionally, new built-in |
| 480 | objects written in C can define what \keyword{in} means for them via a |
| 481 | new slot in the sequence protocol. |
| 482 | |
| 483 | Earlier versions of Python used a recursive algorithm for deleting |
| 484 | objects. Deeply nested data structures could cause the interpreter to |
| 485 | fill up the C stack and crash; Christian Tismer rewrote the deletion |
| 486 | logic to fix this problem. On a related note, comparing recursive |
| 487 | objects recursed infinitely and crashed; Jeremy Hylton rewrote the |
| 488 | code to no longer crash, producing a useful result instead. For |
| 489 | example, after this code: |
| 490 | |
| 491 | \begin{verbatim} |
| 492 | a = [] |
| 493 | b = [] |
| 494 | a.append(a) |
| 495 | b.append(b) |
| 496 | \end{verbatim} |
| 497 | |
| 498 | The comparison \code{a==b} returns true, because the two recursive |
| 499 | data structures are isomorphic. \footnote{See the thread ``trashcan |
| 500 | and PR\#7'' in the April 2000 archives of the python-dev mailing list |
| 501 | for the discussion leading up to this implementation, and some useful |
| 502 | relevant links. |
| 503 | %http://www.python.org/pipermail/python-dev/2000-April/004834.html |
| 504 | } |
| 505 | |
| 506 | Work has been done on porting Python to 64-bit Windows on the Itanium |
| 507 | processor, mostly by Trent Mick of ActiveState. (Confusingly, |
| 508 | \code{sys.platform} is still \code{'win32'} on Win64 because it seems |
| 509 | that for ease of porting, MS Visual C++ treats code as 32 bit on Itanium.) |
| 510 | PythonWin also supports Windows CE; see the Python CE page at |
| 511 | \url{http://starship.python.net/crew/mhammond/ce/} for more |
| 512 | information. |
| 513 | |
| 514 | An attempt has been made to alleviate one of Python's warts, the |
| 515 | often-confusing \exception{NameError} exception when code refers to a |
| 516 | local variable before the variable has been assigned a value. For |
| 517 | example, the following code raises an exception on the \keyword{print} |
| 518 | statement in both 1.5.2 and 2.0; in 1.5.2 a \exception{NameError} |
| 519 | exception is raised, while 2.0 raises a new |
| 520 | \exception{UnboundLocalError} exception. |
| 521 | \exception{UnboundLocalError} is a subclass of \exception{NameError}, |
| 522 | so any existing code that expects \exception{NameError} to be raised |
| 523 | should still work. |
| 524 | |
| 525 | \begin{verbatim} |
| 526 | def f(): |
| 527 | print "i=",i |
| 528 | i = i + 1 |
| 529 | f() |
| 530 | \end{verbatim} |
| 531 | |
| 532 | \subsection{Changes to Built-in Functions} |
| 533 | |
| 534 | A new built-in, \function{zip(\var{seq1}, \var{seq2}, ...)}, has been |
| 535 | added. \function{zip()} returns a list of tuples where each tuple |
| 536 | contains the i-th element from each of the argument sequences. The |
| 537 | difference 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. |
| 541 | |
| 542 | The \function{int()} and \function{long()} functions now accept an |
| 543 | optional ``base'' parameter when the first argument is a string. |
| 544 | \code{int('123', 10)} returns 123, while \code{int('123', 16)} returns |
| 545 | 291. \code{int(123, 16)} raises a \exception{TypeError} exception |
| 546 | with the message ``can't convert non-string with explicit base''. |
| 547 | |
| 548 | A new variable holding more detailed version information has been |
| 549 | added to the \module{sys} module. \code{sys.version_info} is a tuple |
| 550 | \code{(\var{major}, \var{minor}, \var{micro}, \var{level}, |
| 551 | \var{serial})} For example, in a hypothetical 2.0.1beta1, |
| 552 | \code{sys.version_info} would be \code{(2, 0, 1, 'beta', 1)}. |
| 553 | \var{level} is a string such as \code{"alpha"}, \code{"beta"}, or |
| 554 | \code{""} for a final release. |
| 555 | |
| 556 | Dictionaries have an odd new method, \method{setdefault(\var{key}, |
| 557 | \var{default})}, which behaves similarly to the existing |
| 558 | \method{get()} method. However, if the key is missing, |
| 559 | \method{setdefault()} both returns the value of \var{default} as |
| 560 | \method{get()} would do, and also inserts it into the dictionary as |
| 561 | the value for \var{key}. Thus, the following lines of code: |
| 562 | |
| 563 | \begin{verbatim} |
| 564 | if dict.has_key( key ): return dict[key] |
| 565 | else: |
| 566 | dict[key] = [] |
| 567 | return dict[key] |
| 568 | \end{verbatim} |
| 569 | |
| 570 | can be reduced to a single \code{return dict.setdefault(key, [])} statement. |
| 571 | |
Andrew M. Kuchling | 35e8afb | 2000-07-08 12:06:31 +0000 | [diff] [blame] | 572 | |
| 573 | % ====================================================================== |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 574 | \section{Porting to 2.0} |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 575 | |
| 576 | New Python releases try hard to be compatible with previous releases, |
| 577 | and the record has been pretty good. However, some changes are |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 578 | considered useful enough, often fixing initial design decisions that |
| 579 | turned to be actively mistaken, that breaking backward compatibility |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 580 | can't always be avoided. This section lists the changes in Python 2.0 |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 581 | that may cause old Python code to break. |
| 582 | |
| 583 | The change which will probably break the most code is tightening up |
| 584 | the arguments accepted by some methods. Some methods would take |
| 585 | multiple arguments and treat them as a tuple, particularly various |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 586 | list methods such as \method{.append()} and \method{.insert()}. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 587 | In earlier versions of Python, if \code{L} is a list, \code{L.append( |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 588 | 1,2 )} appends the tuple \code{(1,2)} to the list. In Python 2.0 this |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 589 | causes a \exception{TypeError} exception to be raised, with the |
| 590 | message: 'append requires exactly 1 argument; 2 given'. The fix is to |
| 591 | simply add an extra set of parentheses to pass both values as a tuple: |
| 592 | \code{L.append( (1,2) )}. |
| 593 | |
| 594 | The earlier versions of these methods were more forgiving because they |
| 595 | used an old function in Python's C interface to parse their arguments; |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 596 | 2.0 modernizes them to use \function{PyArg_ParseTuple}, the current |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 597 | argument parsing function, which provides more helpful error messages |
| 598 | and treats multi-argument calls as errors. If you absolutely must use |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 599 | 2.0 but can't fix your code, you can edit \file{Objects/listobject.c} |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 600 | and define the preprocessor symbol \code{NO_STRICT_LIST_APPEND} to |
| 601 | preserve the old behaviour; this isn't recommended. |
| 602 | |
| 603 | Some of the functions in the \module{socket} module are still |
| 604 | forgiving in this way. For example, \function{socket.connect( |
| 605 | ('hostname', 25) )} is the correct form, passing a tuple representing |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 606 | an IP address, but \function{socket.connect( 'hostname', 25 )} also |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 607 | works. \function{socket.connect_ex()} and \function{socket.bind()} are |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 608 | similarly easy-going. 2.0alpha1 tightened these functions up, but |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 609 | because the documentation actually used the erroneous multiple |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 610 | argument form, many people wrote code which would break with the |
| 611 | stricter checking. GvR backed out the changes in the face of public |
| 612 | reaction, so for the\module{socket} module, the documentation was |
| 613 | fixed and the multiple argument form is simply marked as deprecated; |
| 614 | it \emph{will} be tightened up again in a future Python version. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 615 | |
| 616 | Some work has been done to make integers and long integers a bit more |
| 617 | interchangeable. In 1.5.2, large-file support was added for Solaris, |
| 618 | to allow reading files larger than 2Gb; this made the \method{tell()} |
| 619 | method of file objects return a long integer instead of a regular |
| 620 | integer. Some code would subtract two file offsets and attempt to use |
| 621 | the result to multiply a sequence or slice a string, but this raised a |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 622 | \exception{TypeError}. In 2.0, long integers can be used to multiply |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 623 | or slice a sequence, and it'll behave as you'd intuitively expect it |
| 624 | to; \code{3L * 'abc'} produces 'abcabcabc', and \code{ |
| 625 | (0,1,2,3)[2L:4L]} produces (2,3). Long integers can also be used in |
| 626 | various new places where previously only integers were accepted, such |
| 627 | as in the \method{seek()} method of file objects. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 628 | |
| 629 | The subtlest long integer change of all is that the \function{str()} |
| 630 | of a long integer no longer has a trailing 'L' character, though |
| 631 | \function{repr()} still includes it. The 'L' annoyed many people who |
| 632 | wanted to print long integers that looked just like regular integers, |
| 633 | since they had to go out of their way to chop off the character. This |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 634 | is no longer a problem in 2.0, but code which assumes the 'L' is |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 635 | there, and does \code{str(longval)[:-1]} will now lose the final |
| 636 | digit. |
| 637 | |
| 638 | Taking the \function{repr()} of a float now uses a different |
| 639 | formatting precision than \function{str()}. \function{repr()} uses |
Andrew M. Kuchling | 662d76e | 2000-06-25 14:32:48 +0000 | [diff] [blame] | 640 | \code{\%.17g} format string for C's \function{sprintf()}, while |
| 641 | \function{str()} uses \code{\%.12g} as before. The effect is that |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 642 | \function{repr()} may occasionally show more decimal places than |
| 643 | \function{str()}, for numbers |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 644 | For example, the number 8.1 can't be represented exactly in binary, so |
| 645 | \code{repr(8.1)} is \code{'8.0999999999999996'}, while str(8.1) is |
| 646 | \code{'8.1'}. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 647 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 648 | The \code{-X} command-line option, which turned all standard |
Andrew M. Kuchling | 62cdd96 | 2000-06-30 12:46:41 +0000 | [diff] [blame] | 649 | exceptions into strings instead of classes, has been removed; the |
| 650 | standard exceptions will now always be classes. The |
| 651 | \module{exceptions} module containing the standard exceptions was |
| 652 | translated from Python to a built-in C module, written by Barry Warsaw |
| 653 | and Fredrik Lundh. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 654 | |
Andrew M. Kuchling | 791b366 | 2000-07-01 15:04:18 +0000 | [diff] [blame] | 655 | % Commented out for now -- I don't think anyone will care. |
| 656 | %The pattern and match objects provided by SRE are C types, not Python |
| 657 | %class instances as in 1.5. This means you can no longer inherit from |
| 658 | %\class{RegexObject} or \class{MatchObject}, but that shouldn't be much |
| 659 | %of a problem since no one should have been doing that in the first |
| 660 | %place. |
| 661 | |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 662 | % ====================================================================== |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 663 | \section{Extending/Embedding Changes} |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 664 | |
| 665 | Some of the changes are under the covers, and will only be apparent to |
Andrew M. Kuchling | 8357c4c | 2000-07-01 00:14:43 +0000 | [diff] [blame] | 666 | people writing C extension modules or embedding a Python interpreter |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 667 | in a larger application. If you aren't dealing with Python's C API, |
Andrew M. Kuchling | 5b8311e | 2000-05-31 03:28:42 +0000 | [diff] [blame] | 668 | you can safely skip this section. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 669 | |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 670 | The version number of the Python C API was incremented, so C |
| 671 | extensions compiled for 1.5.2 must be recompiled in order to work with |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 672 | 2.0. On Windows, attempting to import a third party extension built |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 673 | for Python 1.5.x usually results in an immediate crash; there's not |
Andrew M. Kuchling | 62cdd96 | 2000-06-30 12:46:41 +0000 | [diff] [blame] | 674 | much we can do about this. (Here's Mark Hammond's explanation of the |
| 675 | reasons for the crash. The 1.5 module is linked against |
| 676 | \file{Python15.dll}. When \file{Python.exe} , linked against |
| 677 | \file{Python16.dll}, starts up, it initializes the Python data |
| 678 | structures in \file{Python16.dll}. When Python then imports the |
| 679 | module \file{foo.pyd} linked against \file{Python15.dll}, it |
| 680 | immediately tries to call the functions in that DLL. As Python has |
| 681 | not been initialized in that DLL, the program immediately crashes.) |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 682 | |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 683 | Users of Jim Fulton's ExtensionClass module will be pleased to find |
| 684 | out that hooks have been added so that ExtensionClasses are now |
| 685 | supported by \function{isinstance()} and \function{issubclass()}. |
| 686 | This means you no longer have to remember to write code such as |
| 687 | \code{if type(obj) == myExtensionClass}, but can use the more natural |
| 688 | \code{if isinstance(obj, myExtensionClass)}. |
| 689 | |
Andrew M. Kuchling | b853ea0 | 2000-06-03 03:06:58 +0000 | [diff] [blame] | 690 | The \file{Python/importdl.c} file, which was a mass of \#ifdefs to |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 691 | support dynamic loading on many different platforms, was cleaned up |
Andrew M. Kuchling | 69db0e4 | 2000-06-28 02:16:00 +0000 | [diff] [blame] | 692 | and reorganised by Greg Stein. \file{importdl.c} is now quite small, |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 693 | and platform-specific code has been moved into a bunch of |
Andrew M. Kuchling | b9fb1f2 | 2000-08-04 12:40:35 +0000 | [diff] [blame] | 694 | \file{Python/dynload_*.c} files. Another cleanup: there were also a |
| 695 | number of \file{my*.h} files in the Include/ directory that held |
| 696 | various portability hacks; they've been merged into a single file, |
| 697 | \file{Include/pyport.h}. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 698 | |
| 699 | Vladimir Marangozov's long-awaited malloc restructuring was completed, |
| 700 | to make it easy to have the Python interpreter use a custom allocator |
| 701 | instead of C's standard \function{malloc()}. For documentation, read |
Andrew M. Kuchling | 2d2dc9f | 2000-08-17 00:27:06 +0000 | [diff] [blame] | 702 | the comments in \file{Include/pymem.h} and |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 703 | \file{Include/objimpl.h}. For the lengthy discussions during which |
| 704 | the interface was hammered out, see the Web archives of the 'patches' |
| 705 | and 'python-dev' lists at python.org. |
| 706 | |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 707 | Recent versions of the GUSI development environment for MacOS support |
| 708 | POSIX threads. Therefore, Python's POSIX threading support now works |
| 709 | on the Macintosh. Threading support using the user-space GNU \texttt{pth} |
| 710 | library was also contributed. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 711 | |
| 712 | Threading support on Windows was enhanced, too. Windows supports |
| 713 | thread locks that use kernel objects only in case of contention; in |
| 714 | the common case when there's no contention, they use simpler functions |
| 715 | which are an order of magnitude faster. A threaded version of Python |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 716 | 1.5.2 on NT is twice as slow as an unthreaded version; with the 2.0 |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 717 | changes, the difference is only 10\%. These improvements were |
| 718 | contributed by Yakov Markovitch. |
| 719 | |
Andrew M. Kuchling | 08d87c6 | 2000-07-09 15:05:15 +0000 | [diff] [blame] | 720 | Python 2.0's source now uses only ANSI C prototypes, so compiling Python now |
| 721 | requires an ANSI C compiler, and can no longer be done using a compiler that |
| 722 | only supports K\&R C. |
| 723 | |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 724 | % ====================================================================== |
Andrew M. Kuchling | 4373764 | 2000-08-30 00:51:02 +0000 | [diff] [blame] | 725 | \section{Distutils: Making Modules Easy to Install} |
| 726 | |
| 727 | Before Python 2.0, installing modules was a tedious affair -- there |
| 728 | was no way to figure out automatically where Python is installed, or |
| 729 | what compiler options to use for extension modules. Software authors |
| 730 | had to go through an ardous ritual of editing Makefiles and |
| 731 | configuration files, which only really work on Unix and leave Windows |
| 732 | and MacOS unsupported. Software users faced wildly differing |
| 733 | installation instructions |
| 734 | |
| 735 | The SIG for distribution utilities, shepherded by Greg Ward, has |
| 736 | created the Distutils, a system to make package installation much |
| 737 | easier. They form the \module{distutils} package, a new part of |
| 738 | Python's standard library. In the best case, installing a Python |
| 739 | module from source will require the same steps: first you simply mean |
| 740 | unpack the tarball or zip archive, and the run ``\code{python setup.py |
| 741 | install}''. The platform will be automatically detected, the compiler |
| 742 | will be recognized, C extension modules will be compiled, and the |
| 743 | distribution installed into the proper directory. Optional |
| 744 | command-line arguments provide more control over the installation |
| 745 | process, the distutils package offers many places to override defaults |
| 746 | -- separating the build from the install, building or installing in |
| 747 | non-default directories, and more. |
| 748 | |
| 749 | In order to use the Distutils, you need to write a \file{setup.py} |
| 750 | script. For the simple case, when the software contains only .py |
| 751 | files, a minimal \file{setup.py} can be just a few lines long: |
| 752 | |
| 753 | \begin{verbatim} |
| 754 | from distutils.core import setup |
| 755 | setup (name = "foo", version = "1.0", |
| 756 | py_modules = ["module1", "module2"]) |
| 757 | \end{verbatim} |
| 758 | |
| 759 | The \file{setup.py} file isn't much more complicated if the software |
| 760 | consists of a few packages: |
| 761 | |
| 762 | \begin{verbatim} |
| 763 | from distutils.core import setup |
| 764 | setup (name = "foo", version = "1.0", |
| 765 | packages = ["package", "package.subpackage"]) |
| 766 | \end{verbatim} |
| 767 | |
| 768 | A C extension can be the most complicated case; here's an example taken from |
| 769 | the PyXML package: |
| 770 | |
| 771 | |
| 772 | \begin{verbatim} |
| 773 | from distutils.core import setup, Extension |
| 774 | |
| 775 | expat_extension = Extension('xml.parsers.pyexpat', |
| 776 | define_macros = [('XML_NS', None)], |
| 777 | include_dirs = [ 'extensions/expat/xmltok', |
| 778 | 'extensions/expat/xmlparse' ], |
| 779 | sources = [ 'extensions/pyexpat.c', |
| 780 | 'extensions/expat/xmltok/xmltok.c', |
| 781 | 'extensions/expat/xmltok/xmlrole.c', |
| 782 | ] |
| 783 | ) |
| 784 | setup (name = "PyXML", version = "0.5.4", |
| 785 | ext_modules =[ expat_extension ] ) |
| 786 | |
| 787 | \end{verbatim} |
| 788 | |
| 789 | The Distutils can also take care of creating source and binary |
| 790 | distributions. The ``sdist'' command, run by ``\code{python setup.py |
| 791 | sdist}', builds a source distribution such as \file{foo-1.0.tar.gz}. |
| 792 | Adding new commands isn't difficult, ``bdist_rpm'' and |
| 793 | ``bdist_wininst'' commands have already been contributed to create an |
| 794 | RPM distribution and a Windows installer for the software, |
| 795 | respectively. Commands to create other distribution formats such as |
| 796 | Debian packages and Solaris \file{.pkg} files are in various stages of |
| 797 | development. |
| 798 | |
| 799 | All this is documented in a new manual, \textit{Distributing Python |
| 800 | Modules}, that joins the basic set of Python documentation. |
| 801 | |
| 802 | % ====================================================================== |
| 803 | %\section{New XML Code} |
| 804 | |
| 805 | %XXX write this section... |
| 806 | |
| 807 | % ====================================================================== |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 808 | \section{Module changes} |
| 809 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 810 | Lots of improvements and bugfixes were made to Python's extensive |
| 811 | standard library; some of the affected modules include |
| 812 | \module{readline}, \module{ConfigParser}, \module{cgi}, |
| 813 | \module{calendar}, \module{posix}, \module{readline}, \module{xmllib}, |
| 814 | \module{aifc}, \module{chunk, wave}, \module{random}, \module{shelve}, |
| 815 | and \module{nntplib}. Consult the CVS logs for the exact |
| 816 | patch-by-patch details. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 817 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 818 | Brian Gallew contributed OpenSSL support for the \module{socket} |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 819 | module. OpenSSL is an implementation of the Secure Socket Layer, |
| 820 | which encrypts the data being sent over a socket. When compiling |
| 821 | Python, you can edit \file{Modules/Setup} to include SSL support, |
| 822 | which adds an additional function to the \module{socket} module: |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 823 | \function{socket.ssl(\var{socket}, \var{keyfile}, \var{certfile})}, |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 824 | which takes a socket object and returns an SSL socket. The |
| 825 | \module{httplib} and \module{urllib} modules were also changed to |
| 826 | support ``https://'' URLs, though no one has implemented FTP or SMTP |
| 827 | over SSL. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 828 | |
Andrew M. Kuchling | 69db0e4 | 2000-06-28 02:16:00 +0000 | [diff] [blame] | 829 | The \module{httplib} module has been rewritten by Greg Stein to |
| 830 | support HTTP/1.1. Backward compatibility with the 1.5 version of |
| 831 | \module{httplib} is provided, though using HTTP/1.1 features such as |
| 832 | pipelining will require rewriting code to use a different set of |
| 833 | interfaces. |
| 834 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 835 | The \module{Tkinter} module now supports Tcl/Tk version 8.1, 8.2, or |
| 836 | 8.3, and support for the older 7.x versions has been dropped. The |
Andrew M. Kuchling | 791b366 | 2000-07-01 15:04:18 +0000 | [diff] [blame] | 837 | Tkinter 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, |
| 840 | especially when using lots of coordinates. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 841 | |
Andrew M. Kuchling | fa33a4e | 2000-06-03 02:52:40 +0000 | [diff] [blame] | 842 | The \module{curses} module has been greatly extended, starting from |
| 843 | Oliver Andrich's enhanced version, to provide many additional |
| 844 | functions from ncurses and SYSV curses, such as colour, alternative |
Andrew M. Kuchling | 69db0e4 | 2000-06-28 02:16:00 +0000 | [diff] [blame] | 845 | character set support, pads, and mouse support. This means the module |
| 846 | is no longer compatible with operating systems that only have BSD |
| 847 | curses, but there don't seem to be any currently maintained OSes that |
| 848 | fall into this category. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 849 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 850 | As mentioned in the earlier discussion of 2.0's Unicode support, the |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 851 | underlying implementation of the regular expressions provided by the |
| 852 | \module{re} module has been changed. SRE, a new regular expression |
| 853 | engine written by Fredrik Lundh and partially funded by Hewlett |
| 854 | Packard, supports matching against both 8-bit strings and Unicode |
| 855 | strings. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 856 | |
| 857 | % ====================================================================== |
| 858 | \section{New modules} |
| 859 | |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 860 | A number of new modules were added. We'll simply list them with brief |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 861 | descriptions; consult the 2.0 documentation for the details of a |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 862 | particular module. |
| 863 | |
| 864 | \begin{itemize} |
| 865 | |
Andrew M. Kuchling | 62cdd96 | 2000-06-30 12:46:41 +0000 | [diff] [blame] | 866 | \item{\module{atexit}}: |
| 867 | For registering functions to be called before the Python interpreter exits. |
| 868 | Code that currently sets |
| 869 | \code{sys.exitfunc} directly should be changed to |
| 870 | use the \module{atexit} module instead, importing \module{atexit} |
| 871 | and calling \function{atexit.register()} with |
| 872 | the function to be called on exit. |
| 873 | (Contributed by Skip Montanaro.) |
| 874 | |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 875 | \item{\module{codecs}, \module{encodings}, \module{unicodedata}:} Added as part of the new Unicode support. |
| 876 | |
Andrew M. Kuchling | fed4f1e | 2000-07-01 12:33:43 +0000 | [diff] [blame] | 877 | \item{\module{filecmp}:} Supersedes the old \module{cmp}, \module{cmpcache} and |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 878 | \module{dircmp} modules, which have now become deprecated. |
Andrew M. Kuchling | c0328f0 | 2000-06-10 15:11:20 +0000 | [diff] [blame] | 879 | (Contributed by Gordon MacMillan and Moshe Zadka.) |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 880 | |
Andrew M. Kuchling | 35e8afb | 2000-07-08 12:06:31 +0000 | [diff] [blame] | 881 | \item{\module{linuxaudiodev}:} Support for the \file{/dev/audio} |
| 882 | device on Linux, a twin to the existing \module{sunaudiodev} module. |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 883 | (Contributed by Peter Bosch.) |
| 884 | |
| 885 | \item{\module{mmap}:} An interface to memory-mapped files on both |
| 886 | Windows and Unix. A file's contents can be mapped directly into |
| 887 | memory, at which point it behaves like a mutable string, so its |
| 888 | contents can be read and modified. They can even be passed to |
| 889 | functions that expect ordinary strings, such as the \module{re} |
| 890 | module. (Contributed by Sam Rushing, with some extensions by |
| 891 | A.M. Kuchling.) |
| 892 | |
Andrew M. Kuchling | 35e8afb | 2000-07-08 12:06:31 +0000 | [diff] [blame] | 893 | \item{\module{pyexpat}:} An interface to the Expat XML parser. |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 894 | (Contributed by Paul Prescod.) |
| 895 | |
| 896 | \item{\module{robotparser}:} Parse a \file{robots.txt} file, which is |
| 897 | used 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 |
| 899 | builds a set of rules from it, and can then answer questions about |
| 900 | the fetchability of a given URL. (Contributed by Skip Montanaro.) |
| 901 | |
| 902 | \item{\module{tabnanny}:} A module/script to |
| 903 | checks Python source code for ambiguous indentation. |
| 904 | (Contributed by Tim Peters.) |
| 905 | |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 906 | \item{\module{UserString}:} A base class useful for deriving objects that behave like strings. |
| 907 | |
Andrew M. Kuchling | 08d87c6 | 2000-07-09 15:05:15 +0000 | [diff] [blame] | 908 | \item{\module{webbrowser}:} A module that provides a platform independent |
| 909 | way to launch a web browser on a specific URL. For each platform, various |
| 910 | browsers are tried in a specific order. The user can alter which browser |
| 911 | is launched by setting the \var{BROWSER} environment variable. |
| 912 | (Originally inspired by Eric S. Raymond's patch to \module{urllib} |
| 913 | which added similar functionality, but |
| 914 | the final module comes from code originally |
| 915 | implemented by Fred Drake as \file{Tools/idle/BrowserControl.py}, |
| 916 | and adapted for the standard library by Fred.) |
| 917 | |
Andrew M. Kuchling | 62cdd96 | 2000-06-30 12:46:41 +0000 | [diff] [blame] | 918 | \item{\module{winreg} and \module{_winreg}:} An interface to the |
Andrew M. Kuchling | fed4f1e | 2000-07-01 12:33:43 +0000 | [diff] [blame] | 919 | Windows registry. \module{_winreg} is an adaptation of functions that |
| 920 | have been part of PythonWin since 1995, but has now been added to the core |
| 921 | distribution, and enhanced to support Unicode. \module{winreg} is an |
| 922 | object-oriented API on top of the \module{_winreg} module. |
| 923 | \module{_winreg} was written by Bill Tutt and Mark Hammond, and \module{winreg} |
| 924 | was designed by Thomas Heller and implemented by Paul Prescod. |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 925 | |
| 926 | \item{\module{zipfile}:} A module for reading and writing ZIP-format |
| 927 | archives. These are archives produced by \program{PKZIP} on |
| 928 | DOS/Windows or \program{zip} on Unix, not to be confused with |
| 929 | \program{gzip}-format files (which are supported by the \module{gzip} |
| 930 | module) |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 931 | (Contributed by James C. Ahlstrom.) |
| 932 | |
Andrew M. Kuchling | 69db0e4 | 2000-06-28 02:16:00 +0000 | [diff] [blame] | 933 | \item{\module{imputil}:} A module that provides a simpler way for |
| 934 | writing customised import hooks, in comparison to the existing |
| 935 | \module{ihooks} module. (Implemented by Greg Stein, with much |
| 936 | discussion on python-dev along the way.) |
| 937 | |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 938 | \end{itemize} |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 939 | |
| 940 | % ====================================================================== |
| 941 | \section{IDLE Improvements} |
| 942 | |
Andrew M. Kuchling | c0328f0 | 2000-06-10 15:11:20 +0000 | [diff] [blame] | 943 | IDLE is the official Python cross-platform IDE, written using Tkinter. |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 944 | Python 2.0 includes IDLE 0.6, which adds a number of new features and |
Andrew M. Kuchling | c0328f0 | 2000-06-10 15:11:20 +0000 | [diff] [blame] | 945 | improvements. A partial list: |
| 946 | |
| 947 | \begin{itemize} |
| 948 | \item UI improvements and optimizations, |
| 949 | especially in the area of syntax highlighting and auto-indentation. |
| 950 | |
| 951 | \item The class browser now shows more information, such as the top |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 952 | level functions in a module. |
Andrew M. Kuchling | c0328f0 | 2000-06-10 15:11:20 +0000 | [diff] [blame] | 953 | |
| 954 | \item Tab width is now a user settable option. When opening an existing Python |
| 955 | file, IDLE automatically detects the indentation conventions, and adapts. |
| 956 | |
| 957 | \item There is now support for calling browsers on various platforms, |
| 958 | used to open the Python documentation in a browser. |
| 959 | |
| 960 | \item IDLE now has a command line, which is largely similar to |
| 961 | the vanilla Python interpreter. |
| 962 | |
| 963 | \item Call tips were added in many places. |
| 964 | |
| 965 | \item IDLE can now be installed as a package. |
| 966 | |
| 967 | \item In the editor window, there is now a line/column bar at the bottom. |
| 968 | |
| 969 | \item Three new keystroke commands: Check module (Alt-F5), Import |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 970 | module (F5) and Run script (Ctrl-F5). |
Andrew M. Kuchling | c0328f0 | 2000-06-10 15:11:20 +0000 | [diff] [blame] | 971 | |
| 972 | \end{itemize} |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 973 | |
| 974 | % ====================================================================== |
| 975 | \section{Deleted and Deprecated Modules} |
| 976 | |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 977 | A few modules have been dropped because they're obsolete, or because |
| 978 | there are now better ways to do the same thing. The \module{stdwin} |
| 979 | module is gone; it was for a platform-independent windowing toolkit |
| 980 | that's no longer developed. |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 981 | |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 982 | A number of modules have been moved to the |
| 983 | \file{lib-old} subdirectory: |
| 984 | \module{cmp}, \module{cmpcache}, \module{dircmp}, \module{dump}, |
| 985 | \module{find}, \module{grep}, \module{packmail}, |
| 986 | \module{poly}, \module{util}, \module{whatsound}, \module{zmod}. |
| 987 | If you have code which relies on a module that's been moved to |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 988 | \file{lib-old}, you can simply add that directory to \code{sys.path} |
Andrew M. Kuchling | a5bbb00 | 2000-06-10 02:41:46 +0000 | [diff] [blame] | 989 | to get them back, but you're encouraged to update any code that uses |
| 990 | these modules. |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 991 | |
Andrew M. Kuchling | 730067e | 2000-06-30 01:44:05 +0000 | [diff] [blame] | 992 | \section{Acknowledgements} |
Andrew M. Kuchling | 6c3cd8d | 2000-06-10 02:24:31 +0000 | [diff] [blame] | 993 | |
Andrew M. Kuchling | a6161ed | 2000-07-01 00:23:02 +0000 | [diff] [blame] | 994 | The authors would like to thank the following people for offering |
Andrew M. Kuchling | 62cdd96 | 2000-06-30 12:46:41 +0000 | [diff] [blame] | 995 | suggestions on drafts of this article: Fredrik Lundh, Skip |
| 996 | Montanaro, Vladimir Marangozov, Guido van Rossum, Neil Schemenauer. |
Andrew M. Kuchling | 25bfd0e | 2000-05-27 11:28:26 +0000 | [diff] [blame] | 997 | |
| 998 | \end{document} |