Augmented Assignment in Python (PER)

David Beazley beazley at cs.uchicago.edu
Tue Jul 17 22:49:07 EDT 2001


Delaney, Timothy writes:
 > > built-in types (if there is such an example, please enlighten me!).
 > 
 > This is very very wrong.
 > 
 > a = []
 > b = a
 > 
 > print b
 > a += [1, 2]
 > print b
 > 
 > List is a built-in type. Lists are modified in-place by augmented
 > assignment.

Noted. Thanks. 

 > The information in your book will lead to bad programming errors.

Oh, I don't think my book has any kind of monopoly on creating
potentially bad programming errors--just look at the PEPs (sic) :-).

Cheers,

Dave








More information about the Python-list mailing list