Deleting objects is safe even for deeply nested data structures.
Comparing recursive objects is now safe (doesn't dump core).
Builds on NT Alpha, and work on Win64 (NT Itanium -- sys.platform is
still 'win32') is ongoing. Supports Windows CE (confirm with Mark
Hammond)
UnboundLocalError is raised when a local variable is undefined
long, int take optional "base" parameter
string objects now have methods (though they are still immutable)
sys.version_info is a tuple: (major, minor, micro, level, serial); level
is a string "a2", "b1", "c1", or '' for a final release.
New format style '%r' inserts repr(arg) instead of str(arg).
"in" operator can now be overriden in user-defined classes to mean anything:
it calls the magic method __contains__
New calling syntax: f(*args, **kw) equivalent to apply(f, args, kw)
Various minor changes have been made to Python's syntax and built-in
functions. None of the changes are very far-reaching, but they're
handy conveniences.
A change to syntax makes it more convenient to call a given function
with a tuple of arguments and/or a dictionary of keyword arguments.
In Python 1.5 and earlier, you do this with the \builtin{apply()}
built-in function: \code{apply(f, \var{args}, \var{kw})} calls the
function \function{f()} with the argument tuple \var{args} and the
keyword arguments in the dictionary \var{kw}. Thanks to a patch from
Greg Ewing, 1.6 adds \code{f(*\var{args}, **\var{kw})} as a shorter
and clearer way to achieve the same effect. This syntax is
symmetrical with the syntax for defining functions:
\begin{verbatim}
def f(*args, **kw):
# args is a tuple of positional args,
# kw is a dictionary of keyword args
...
\end{verbatim}
A new format style is available when using the \operator{\%} operator.
'\%r' will insert the \function{repr()} of its argument. This was
also added from symmetry considerations, this time for symmetry with
the existing '\%s' format style which inserts the \function{str()} of
its argument. For example, \code{'%r %s' % ('abc', 'abc')} returns a
string containing \verb|'abc' abc|.
The \builtin{int()} and \builtin{long()} functions now accept an
optional ``base'' parameter when the first argument is a string.
\code{int('123', 10)} returns 123, while \code{int('123', 16)} returns
291. \code{int(123, 16)} raises a \exception{TypeError} exception
with the message ``can't convert non-string with explicit base''.
Previously there was no way to implement a class that overrode
Python's built-in \operator{in} operator and implemented a custom
version. \code{\var{obj} in \var{seq}} returns true if \var{obj} is
present in the sequence \var{seq}; Python computes this by simply
trying every index of the sequence until either \var{obj} is found or
an \exception{IndexError} is encountered. Moshe Zadka contributed a
patch which adds a \method{__contains__} magic method for providing a
custom implementation for \operator{in}.
Earlier versions of Python used a recursive algorithm for deleting
objects. Deeply nested data structures could cause the interpreter to
fill up the C stack and crash; Christian Tismer rewrote the deletion
logic to fix this problem. On a related note, comparing recursive
objects recursed infinitely and crashed; Jeremy Hylton rewrote the
code to no longer crash, producing a useful result instead. For
example, after this code:
\begin{verbatim}
a = []
b = []
a.append(a)
b.append(b)
\end{verbatim}
The comparison \code{a==b} returns true, because the two recursive
data structures are isomorphic.
\footnote{See the thread ``trashcan and PR\#7'' in the April 2000 archives of the python-dev mailing list for the discussion leading up to this implementation, and some useful relevant links.