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

Fred L. Drake python-dev@python.org
Wed, 12 Jul 2000 21:58:01 -0700


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

Modified Files:
	ref3.tex 
Log Message:

Improve the descriptions of expected exceptions for __getitem__(),
__setitem__(), and __delitem__().  Based on related comments from
Barry Warsaw.


Index: ref3.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref3.tex,v
retrieving revision 1.44
retrieving revision 1.45
diff -C2 -r1.44 -r1.45
*** ref3.tex	2000/06/28 20:15:47	1.44
--- ref3.tex	2000/07/13 04:57:58	1.45
***************
*** 1092,1098 ****
  \begin{methoddesc}[mapping object]{__getitem__}{self, key}
  Called to implement evaluation of \code{\var{self}[\var{key}]}.
! For a sequence types, the accepted keys should be integers.  Note that the
! special interpretation of negative indices (if the class wishes to
  emulate a sequence type) is up to the \method{__getitem__()} method.
  \end{methoddesc}
  
--- 1092,1105 ----
  \begin{methoddesc}[mapping object]{__getitem__}{self, key}
  Called to implement evaluation of \code{\var{self}[\var{key}]}.
! For a sequence types, the accepted keys should be integers.  Note that
! the special interpretation of negative indices (if the class wishes to
  emulate a sequence type) is up to the \method{__getitem__()} method.
+ If \var{key} is of an inappropriate type, \exception{TypeError} may be
+ raised; if of a value outside the set of indexes for the sequence
+ (after any special interpretation of negative values),
+ \exception{IndexError} should be raised.
+ \strong{Note:}  \keyword{for} loops expect that an
+ \exception{IndexError} will be raised for illegal indexes to allow
+ proper detection of the end of the sequence.
  \end{methoddesc}
  
***************
*** 1102,1106 ****
  for mappings if the objects support changes to the values for keys, or
  if new keys can be added, or for sequences if elements can be
! replaced.
  \end{methoddesc}
  
--- 1109,1114 ----
  for mappings if the objects support changes to the values for keys, or
  if new keys can be added, or for sequences if elements can be
! replaced.  The same exceptions should be raised for improper
! \var{key} values as for the \method{__getitem__()} method.
  \end{methoddesc}
  
***************
*** 1109,1113 ****
  note as for \method{__getitem__()}.  This should only be implemented
  for mappings if the objects support removal of keys, or for sequences
! if elements can be removed from the sequence.
  \end{methoddesc}
  
--- 1117,1123 ----
  note as for \method{__getitem__()}.  This should only be implemented
  for mappings if the objects support removal of keys, or for sequences
! if elements can be removed from the sequence.  The same exceptions
! should be raised for improper \var{key} values as for the
! \method{__getitem__()} method.
  \end{methoddesc}