[Python-checkins] python/dist/src/Doc/lib libfuncs.tex,1.123,1.124

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Mon, 16 Dec 2002 17:03:00 -0800


Update of /cvsroot/python/python/dist/src/Doc/lib
In directory sc8-pr-cvs1:/tmp/cvs-serv28958/Doc/lib

Modified Files:
	libfuncs.tex 
Log Message:
Fix SF #642742, property() builtin not documented

Added doc for functions new to 2.2:  classmethod property staticmethod super
Taken from docstrings.  Could use review.
Hope there wasn't a reason why these shouldn't have been added.

Backport candidate.


Index: libfuncs.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/libfuncs.tex,v
retrieving revision 1.123
retrieving revision 1.124
diff -C2 -d -r1.123 -r1.124
*** libfuncs.tex	12 Dec 2002 16:41:38 -0000	1.123
--- libfuncs.tex	17 Dec 2002 01:02:57 -0000	1.124
***************
*** 86,89 ****
--- 86,90 ----
    \code{True}.
  \indexii{Boolean}{type}
+ \versionadded{2.2.1}
  \end{funcdesc}
  
***************
*** 115,118 ****
--- 116,142 ----
  \end{funcdesc}
  
+ \begin{funcdesc}{classmethod}{function}
+   Return a class method for \var{function}.
+ 
+   A class method receives the class as implicit first argument,
+   just like an instance method receives the instance.
+   To declare a class method, use this idiom:
+ 
+ \begin{verbatim}
+ class C:
+     def f(cls, arg1, arg2, ...): ...
+     f = classmethod(f)
+ \end{verbatim}
+ 
+   It can be called either on the class (e.g. C.f()) or on an instance
+   (e.g. C().f()).  The instance is ignored except for its class.
+   If a class method is called for a derived class, the derived class
+   object is passed as the implied first argument.
+ 
+   Class methods are different than C++ or Java static methods.
+   If you want those, see \ref{staticmethod}.
+   \versionadded{2.2}
+ \end{funcdesc}
+ 
  \begin{funcdesc}{cmp}{x, y}
    Compare the two objects \var{x} and \var{y} and return an integer
***************
*** 680,683 ****
--- 704,726 ----
  \end{funcdesc}
  
+ \begin{funcdesc}{property}{\optional{fget\optional{, fset\optional{, fdel\optional{, doc}}}}}
+   Return a property attribute for new-style classes (classes that
+   derive from \function{object}.
+ 
+   \var{fget} is a function for getting an attribute value, likewise
+   \var{fset} is a function for setting, and \var{fdel} a function
+   for del'ing, an attribute.  Typical use is to define a managed attribute x:
+ 
+ \begin{verbatim}
+ class C(object):
+     def getx(self): return self.__x
+     def setx(self, value): self.__x = value
+     def delx(self): del self.__x
+         x = property(getx, setx, delx, "I'm the 'x' property.")
+ \end{verbatim}
+ 
+   \versionadded{2.2}
+ \end{funcdesc}
+ 
  \begin{funcdesc}{range}{\optional{start,} stop\optional{, step}}
    This is a versatile function to create lists containing arithmetic
***************
*** 825,828 ****
--- 868,906 ----
    indexing syntax is used.  For example: \samp{a[start:stop:step]} or
    \samp{a[start:stop, i]}.
+ \end{funcdesc}
+ 
+ \begin{funcdesc}{staticmethod}{function}
+   Return a static method for \var{function}.
+ 
+   A static method does not receive an implicit first argument.
+   To declare a static method, use this idiom:
+ 
+ \begin{verbatim}
+ class C:
+     def f(arg1, arg2, ...): ...
+     f = staticmethod(f)
+ \end{verbatim}
+ 
+   It can be called either on the class (e.g. C.f()) or on an instance
+   (e.g. C().f()).  The instance is ignored except for its class.
+ 
+   Static methods in Python are similar to those found in Java or C++.
+   For a more advanced concept, see \ref{classmethod}.
+   \versionadded{2.2}
+ \end{funcdesc}
+ 
+ \begin{funcdesc}{super}{type\optional{object-or-type}}
+   Return the superclass of \var{type}.  If the second argument is omitted
+   the super object returned is unbound.  If the second argument is an
+   object, isinstance(obj, type) must be true.  If the second argument is a
+   type, issubclass(type2, type) must be true.
+ 
+   A typical use for calling a cooperative superclass method is:
+ \begin{verbatim}
+ class C(B):
+     def meth(self, arg):
+         super(C, self).meth(arg)
+ \end{verbatim}
+ \versionadded{2.2}
  \end{funcdesc}