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

Thomas Wouters python-dev@python.org
Thu, 17 Aug 2000 15:37:34 -0700


Update of /cvsroot/python/python/dist/src/Doc/ref
In directory slayer.i.sourceforge.net:/tmp/cvs-serv3945/Doc/ref

Modified Files:
	ref3.tex 
Log Message:

Apply SF patch #101029: call __getitem__ with a proper slice object if there
is no __getslice__ available. Also does the same for C extension types.
Includes rudimentary documentation (it could use a cross reference to the
section on slice objects, I couldn't figure out how to do that) and a test
suite for all Python __hooks__ I could think of, including the new
behaviour.



Index: ref3.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v
retrieving revision 1.46
retrieving revision 1.47
diff -C2 -r1.46 -r1.47
*** ref3.tex	2000/07/16 19:05:38	1.46
--- ref3.tex	2000/08/17 22:37:31	1.47
***************
*** 1043,1051 ****
  sequence, the allowable keys should be the integers \var{k} for which
  \code{0 <= \var{k} < \var{N}} where \var{N} is the length of the
! sequence, and the method \method{__getslice__()} (see below) should be
! defined.  It is also recommended that mappings provide methods
! \method{keys()}, \method{values()}, \method{items()},
! \method{has_key()}, \method{get()}, \method{clear()}, \method{copy()},
! and \method{update()} behaving similar to those for
  Python's standard dictionary objects; mutable sequences should provide
  methods \method{append()}, \method{count()}, \method{index()},
--- 1043,1052 ----
  sequence, the allowable keys should be the integers \var{k} for which
  \code{0 <= \var{k} < \var{N}} where \var{N} is the length of the
! sequence, or slice objects, which define a range of items. (For backwards
! compatibility, the method \method{__getslice__()} (see below) can also be
! defined to handle simple, but not extended slices.) It is also recommended
! that mappings provide methods \method{keys()}, \method{values()},
! \method{items()}, \method{has_key()}, \method{get()}, \method{clear()},
! \method{copy()}, and \method{update()} behaving similar to those for
  Python's standard dictionary objects; mutable sequences should provide
  methods \method{append()}, \method{count()}, \method{index()},
***************
*** 1142,1145 ****
--- 1143,1148 ----
  negative.  Indexes which are greater than the length of the sequence
  are not modified.
+ This method is deprecated. If no \method{__getslice__()} is found, a slice
+ object is created instead, and passed to \method{__getitem__()} instead.
  \end{methoddesc}
  
***************
*** 1147,1150 ****
--- 1150,1156 ----
  Called to implement assignment to \code{\var{self}[\var{i}:\var{j}]}.
  Same notes for \var{i} and \var{j} as for \method{__getslice__()}.
+ 
+ This method is deprecated. If no \method{__setslice__()} is found, a slice
+ object is created instead, and passed to \method{__setitem__()} instead.
  \end{methoddesc}
  
***************
*** 1152,1161 ****
  Called to implement deletion of \code{\var{self}[\var{i}:\var{j}]}.
  Same notes for \var{i} and \var{j} as for \method{__getslice__()}.
  \end{methoddesc}
  
! Notice that these methods are only invoked when a single slice with a
! single colon is used.  For slice operations involving extended slice
! notation, \method{__getitem__()}, \method{__setitem__()}
! or\method{__delitem__()} is called.
  
  
--- 1158,1170 ----
  Called to implement deletion of \code{\var{self}[\var{i}:\var{j}]}.
  Same notes for \var{i} and \var{j} as for \method{__getslice__()}.
+ This method is deprecated. If no \method{__delslice__()} is found, a slice
+ object is created instead, and passed to \method{__delitem__()} instead.
  \end{methoddesc}
  
! Notice that these methods are only invoked when a single slice with a single
! colon is used, and the slice method is available.  For slice operations
! involving extended slice notation, or in absence of the slice methods,
! \method{__getitem__()}, \method{__setitem__()} or \method{__delitem__()} is
! called with a slice object as argument.