diff options
author | Raymond Hettinger <python@rcn.com> | 2002-06-25 13:36:41 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2002-06-25 13:36:41 (GMT) |
commit | 04e7e0c60fa1d7edea0a5e39285fd18bbcc4107b (patch) | |
tree | bf325cb3dd36d6df1449f09224b934a258fa8364 /Doc/ref | |
parent | 8345f719c859bac6c31146f402e5bca9c0ac0631 (diff) | |
download | cpython-04e7e0c60fa1d7edea0a5e39285fd18bbcc4107b.zip cpython-04e7e0c60fa1d7edea0a5e39285fd18bbcc4107b.tar.gz cpython-04e7e0c60fa1d7edea0a5e39285fd18bbcc4107b.tar.bz2 |
Close bug 417930 by clarifying augmented assignment docs
Diffstat (limited to 'Doc/ref')
-rw-r--r-- | Doc/ref/ref6.tex | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex index 12261e2..80fae5a 100644 --- a/Doc/ref/ref6.tex +++ b/Doc/ref/ref6.tex @@ -300,6 +300,20 @@ the same way as normal assignments. Similarly, with the exception of the possible \emph{in-place} behavior, the binary operation performed by 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}} \stindex{pass} |