[Python-checkins] CVS: python/dist/src/Doc/ref ref3.tex,1.71,1.72

Fred L. Drake fdrake@users.sourceforge.net
Tue, 14 Aug 2001 13:28:10 -0700


Update of /cvsroot/python/python/dist/src/Doc/ref
In directory usw-pr-cvs1:/tmp/cvs-serv31630/ref

Modified Files:
	ref3.tex 
Log Message:

Add information about __floordiv__() and __truediv__() methods for
implementing numeric objects in Python.


Index: ref3.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v
retrieving revision 1.71
retrieving revision 1.72
diff -C2 -d -r1.71 -r1.72
*** ref3.tex	2001/08/02 21:34:53	1.71
--- ref3.tex	2001/08/14 20:28:08	1.72
***************
*** 1331,1335 ****
  \methodline[numeric object]{__sub__}{self, other}
  \methodline[numeric object]{__mul__}{self, other}
! \methodline[numeric object]{__div__}{self, other}
  \methodline[numeric object]{__mod__}{self, other}
  \methodline[numeric object]{__divmod__}{self, other}
--- 1331,1335 ----
  \methodline[numeric object]{__sub__}{self, other}
  \methodline[numeric object]{__mul__}{self, other}
! \methodline[numeric object]{__floordiv__}{self, other}
  \methodline[numeric object]{__mod__}{self, other}
  \methodline[numeric object]{__divmod__}{self, other}
***************
*** 1340,1346 ****
  \methodline[numeric object]{__xor__}{self, other}
  \methodline[numeric object]{__or__}{self, other}
! These functions are
  called to implement the binary arithmetic operations (\code{+},
! \code{-}, \code{*}, \code{/}, \code{\%},
  \function{divmod()}\bifuncindex{divmod},
  \function{pow()}\bifuncindex{pow}, \code{**}, \code{<}\code{<},
--- 1340,1346 ----
  \methodline[numeric object]{__xor__}{self, other}
  \methodline[numeric object]{__or__}{self, other}
! These methods are
  called to implement the binary arithmetic operations (\code{+},
! \code{-}, \code{*}, \code{//}, \code{\%},
  \function{divmod()}\bifuncindex{divmod},
  \function{pow()}\bifuncindex{pow}, \code{**}, \code{<}\code{<},
***************
*** 1348,1352 ****
  evaluate the expression \var{x}\code{+}\var{y}, where \var{x} is an
  instance of a class that has an \method{__add__()} method,
! \code{\var{x}.__add__(\var{y})} is called.  Note that
  \method{__pow__()} should be defined to accept an optional third
  argument if the ternary version of the built-in
--- 1348,1355 ----
  evaluate the expression \var{x}\code{+}\var{y}, where \var{x} is an
  instance of a class that has an \method{__add__()} method,
! \code{\var{x}.__add__(\var{y})} is called.  The \method{__divmod__()}
! method should be the equivalent to using \method{__floordiv__()} and
! \method{__mod__()}; it should not be related to \method{__truediv__()}
! (described below).  Note that
  \method{__pow__()} should be defined to accept an optional third
  argument if the ternary version of the built-in
***************
*** 1354,1357 ****
--- 1357,1369 ----
  \end{methoddesc}
  
+ \begin{methoddesc}[numeric object]{__div__}{self, other}
+ \methodline[numeric object]{__truediv__}{self, other}
+ The division operator (\code{/}) is implemented by these methods.  The
+ \method{__truediv__()} method is used when \code{__future__.division}
+ is in effect, otherwise \method{__div__()} is used.  If only one of
+ these two methods is defined, the object will not support division in
+ the alternate context; \exception{TypeError} will be raised instead.
+ \end{methoddesc}
+ 
  \begin{methoddesc}[numeric object]{__radd__}{self, other}
  \methodline[numeric object]{__rsub__}{self, other}
***************
*** 1366,1370 ****
  \methodline[numeric object]{__rxor__}{self, other}
  \methodline[numeric object]{__ror__}{self, other}
! These functions are
  called to implement the binary arithmetic operations (\code{+},
  \code{-}, \code{*}, \code{/}, \code{\%},
--- 1378,1382 ----
  \methodline[numeric object]{__rxor__}{self, other}
  \methodline[numeric object]{__ror__}{self, other}
! These methods are
  called to implement the binary arithmetic operations (\code{+},
  \code{-}, \code{*}, \code{/}, \code{\%},