[Python-checkins] python/dist/src/Doc/whatsnew whatsnew22.tex,1.54.2.3,1.54.2.4

akuchling@users.sourceforge.net akuchling@users.sourceforge.net
Tue, 20 May 2003 11:13:16 -0700


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

Modified Files:
      Tag: release22-maint
	whatsnew22.tex 
Log Message:
Backport: 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.54.2.3
retrieving revision 1.54.2.4
diff -C2 -d -r1.54.2.3 -r1.54.2.4
*** whatsnew22.tex	27 Nov 2002 18:58:22 -0000	1.54.2.3
--- whatsnew22.tex	20 May 2003 18:13:14 -0000	1.54.2.4
***************
*** 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__}.
+