From: A.M. K. <aku...@us...> - 2001-12-21 04:39:14
|
Update of /cvsroot/py-howto/pyhowto In directory usw-pr-cvs1:/tmp/cvs-serv3833 Modified Files: python-22.tex Log Message: 1.00 at last! Describe super() very briefly A few minor reformattings and wording changes Set the release date (presumably tomorrow...) Index: python-22.tex =================================================================== RCS file: /cvsroot/py-howto/pyhowto/python-22.tex,v retrieving revision 1.53 retrieving revision 1.54 diff -C2 -r1.53 -r1.54 *** python-22.tex 2001/12/20 16:33:45 1.53 --- python-22.tex 2001/12/21 04:39:11 1.54 *************** *** 4,8 **** \title{What's New in Python 2.2} ! \release{0.10} \author{A.M. Kuchling} \authoraddress{\email{aku...@me...}} --- 4,8 ---- \title{What's New in Python 2.2} ! \release{1.00} \author{A.M. Kuchling} \authoraddress{\email{aku...@me...}} *************** *** 12,17 **** \section{Introduction} ! This article explains the new features in Python 2.2. ! The final release of Python 2.2 is planned for December 2001. Python 2.2 can be thought of as the "cleanup release". There are some --- 12,17 ---- \section{Introduction} ! This article explains the new features in Python 2.2, released on ! December 21, 2001. Python 2.2 can be thought of as the "cleanup release". There are some *************** *** 246,250 **** syntax for creating such methods (\code{def static f()}, \code{defstatic f()}, or something like that) but no such syntax has ! been defined yet; that's been left for future versions. More new features, such as slots and properties, are also implemented --- 246,250 ---- syntax for creating such methods (\code{def static f()}, \code{defstatic f()}, or something like that) but no such syntax has ! been defined yet; that's been left for future versions of Python. More new features, such as slots and properties, are also implemented *************** *** 261,268 **** --- 261,271 ---- def f(self, arg1, arg2): # The actual function + ... def pre_f(self): # Check preconditions + ... def post_f(self): # Check postconditions + ... f = eiffelmethod(f, pre_f, post_f) *************** *** 277,280 **** --- 280,284 ---- ignore the implementation details. + \subsection{Multiple Inheritance: The Diamond Rule} *************** *** 327,333 **** Following this rule, referring to \method{D.save()} will return \method{C.save()}, which is the behaviour we're after. This lookup ! rule is the same as the one followed by Common Lisp. ! % XXX mention super() --- 331,356 ---- Following this rule, referring to \method{D.save()} will return \method{C.save()}, which is the behaviour we're after. This lookup ! rule is the same as the one followed by Common Lisp. A new built-in ! function, \function{super()}, provides a way to get at a class's ! superclasses without having to reimplement Python's algorithm. ! The most commonly used form will be ! \function{super(\var{class}, \var{obj})}, which returns ! a bound superclass object (not the actual class object). This form ! will be used in methods to call a method in the superclass; for ! example, \class{D}'s \method{save()} method would look like this: ! ! \begin{verbatim} ! class D: ! def save (self): ! # Call superclass .save() ! super(D, self).save() ! # Save D's private information here ! ... ! \end{verbatim} ! \function{super()} can also return unbound superclass objects ! when called as \function{super(\var{class})} or ! \function{super(\var{class1}, \var{class2})}, but this probably won't ! often be useful. |