File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -300,6 +300,20 @@ \subsection{Augmented assignment statements \label{augassign}}
300300possible \emph {in-place } behavior, the binary operation performed by
301301augmented assignment is the same as the normal binary operations.
302302
303+ For targets which are attribute references, the initial value is
304+ retrieved with a \method {getattr()} and the result is assigned with a
305+ \method {setattr()}. Notice that the two methods do not necessarily
306+ refer to the same variable. When \method {getattr()} refers to a class
307+ variable, \method {setattr()} still writes to an instance variable.
308+ For example:
309+
310+ \begin {verbatim }
311+ class A:
312+ x = 3 # class variable
313+ a = A()
314+ a.x += 1 # writes a.x as 4 leaving A.x as 3
315+ \end {verbatim }
316+
303317
304318\section {The \keyword {pass} statement \label {pass } }
305319\stindex {pass}
You can’t perform that action at this time.
0 commit comments