[Python-checkins] python/dist/src/Doc/ref ref6.tex,1.47.4.1,1.47.4.2

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
Tue, 25 Jun 2002 06:39:51 -0700


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

Modified Files:
      Tag: release22-maint
	ref6.tex 
Log Message:
Close bug 417930 by clarifying augmented assignment docs

Index: ref6.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref6.tex,v
retrieving revision 1.47.4.1
retrieving revision 1.47.4.2
diff -C2 -d -r1.47.4.1 -r1.47.4.2
*** ref6.tex	15 Mar 2002 23:18:05 -0000	1.47.4.1
--- ref6.tex	25 Jun 2002 13:39:49 -0000	1.47.4.2
***************
*** 301,304 ****
--- 301,318 ----
  augmented assignment is the same as the normal binary operations.
  
+ For targets which are attribute references, the initial value is
+ retrieved with a \method{getattr()} and the result is assigned with a
+ \method{setattr()}.  Notice that the two methods do not necessarily
+ refer to the same variable.  When \method{getattr()} refers to a class
+ variable, \method{setattr()} still writes to an instance variable.
+ For example:
+ 
+ \begin{verbatim}
+ class A:
+     x = 3    # class variable
+ a = A()
+ a.x += 1     # writes a.x as 4 leaving A.x as 3
+ \end{verbatim}
+ 
  
  \section{The \keyword{pass} statement \label{pass}}