[Python-checkins] python/dist/src/Doc/whatsnew whatsnew22.tex,1.61,1.62

akuchling@users.sourceforge.net akuchling@users.sourceforge.net
Tue, 20 May 2003 11:12:24 -0700


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

Modified Files:
	whatsnew22.tex 
Log Message:
Don't mention __slots__ as a technique for error avoidance

Index: whatsnew22.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/whatsnew/whatsnew22.tex,v
retrieving revision 1.61
retrieving revision 1.62
diff -C2 -d -r1.61 -r1.62
*** whatsnew22.tex	27 Nov 2002 18:53:38 -0000	1.61
--- whatsnew22.tex	20 May 2003 18:12:21 -0000	1.62
***************
*** 425,436 ****
  Python objects are usually very dynamic; at any time it's possible to
  define a new attribute on an instance by just doing
! \code{obj.new_attr=1}.  This is flexible and convenient, but this
! flexibility can also lead to bugs, as when you meant to write
! \code{obj.template = 'a'} but made a typo and wrote
! \code{obj.templtae} by accident.  
! 
! A new-style class can define a class attribute named \member{__slots__}
! to constrain the list of legal attribute names.  An example will make
! this clear:
  
  \begin{verbatim}
--- 425,431 ----
  Python objects are usually very dynamic; at any time it's possible to
  define a new attribute on an instance by just doing
! \code{obj.new_attr=1}.   A new-style class can define a class attribute named
! \member{__slots__} to limit the legal attributes 
! to a particular set of names.  An example will make this clear:
  
  \begin{verbatim}
***************
*** 444,455 ****
  >>> print obj.template
  Test
! >>> obj.templtae = None
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
! AttributeError: 'C' object has no attribute 'templtae'
  \end{verbatim}
  
  Note how you get an \exception{AttributeError} on the attempt to
  assign to an attribute not listed in \member{__slots__}.
  
  
--- 439,451 ----
  >>> print obj.template
  Test
! >>> obj.newattr = None
  Traceback (most recent call last):
    File "<stdin>", line 1, in ?
! AttributeError: 'C' object has no attribute 'newattr'
  \end{verbatim}
  
  Note how you get an \exception{AttributeError} on the attempt to
  assign to an attribute not listed in \member{__slots__}.
+