Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bec5b36

Browse files
committed
1.00 at last!
Describe super() very briefly A few minor reformattings and wording changes Set the release date (presumably tomorrow...)
1 parent 5c79831 commit bec5b36

1 file changed

Lines changed: 29 additions & 6 deletions

File tree

Doc/whatsnew/whatsnew22.tex

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
% $Id$
44

55
\title{What's New in Python 2.2}
6-
\release{0.10}
6+
\release{1.00}
77
\author{A.M. Kuchling}
88
\authoraddress{\email{[email protected]}}
99
\begin{document}
1010
\maketitle\tableofcontents
1111

1212
\section{Introduction}
1313

14-
This article explains the new features in Python 2.2.
15-
The final release of Python 2.2 is planned for December 2001.
14+
This article explains the new features in Python 2.2, released on
15+
December 21, 2001.
1616

1717
Python 2.2 can be thought of as the "cleanup release". There are some
1818
features such as generators and iterators that are completely new, but
@@ -245,7 +245,7 @@ \subsection{Descriptors}
245245
stored in the class object. You might expect there to be special
246246
syntax for creating such methods (\code{def static f()},
247247
\code{defstatic f()}, or something like that) but no such syntax has
248-
been defined yet; that's been left for future versions.
248+
been defined yet; that's been left for future versions of Python.
249249

250250
More new features, such as slots and properties, are also implemented
251251
as new kinds of descriptors, and it's not difficult to write a
@@ -260,10 +260,13 @@ \subsection{Descriptors}
260260
class C(object):
261261
def f(self, arg1, arg2):
262262
# The actual function
263+
...
263264
def pre_f(self):
264265
# Check preconditions
266+
...
265267
def post_f(self):
266268
# Check postconditions
269+
...
267270
268271
f = eiffelmethod(f, pre_f, post_f)
269272
\end{verbatim}
@@ -276,6 +279,7 @@ \subsection{Descriptors}
276279
users will just write code on top of the resulting libraries and
277280
ignore the implementation details.
278281

282+
279283
\subsection{Multiple Inheritance: The Diamond Rule}
280284

281285
Multiple inheritance has also been made more useful through changing
@@ -326,9 +330,28 @@ \subsection{Multiple Inheritance: The Diamond Rule}
326330

327331
Following this rule, referring to \method{D.save()} will return
328332
\method{C.save()}, which is the behaviour we're after. This lookup
329-
rule is the same as the one followed by Common Lisp.
333+
rule is the same as the one followed by Common Lisp. A new built-in
334+
function, \function{super()}, provides a way to get at a class's
335+
superclasses without having to reimplement Python's algorithm.
336+
The most commonly used form will be
337+
\function{super(\var{class}, \var{obj})}, which returns
338+
a bound superclass object (not the actual class object). This form
339+
will be used in methods to call a method in the superclass; for
340+
example, \class{D}'s \method{save()} method would look like this:
341+
342+
\begin{verbatim}
343+
class D:
344+
def save (self):
345+
# Call superclass .save()
346+
super(D, self).save()
347+
# Save D's private information here
348+
...
349+
\end{verbatim}
330350

331-
% XXX mention super()
351+
\function{super()} can also return unbound superclass objects
352+
when called as \function{super(\var{class})} or
353+
\function{super(\var{class1}, \var{class2})}, but this probably won't
354+
often be useful.
332355

333356

334357
\subsection{Attribute Access}

0 commit comments

Comments
 (0)