Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #41593
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-03-20 07:17 -0700 |
| Message-ID | <b5bfb026-fea4-4aec-8185-cc8837e1559a@googlegroups.com> (permalink) |
| Subject | x += ... is not the same than x = x + ... if x is mutable |
| From | bartolome.sintes@gmail.com |
Hi, I thought that x += ... was the same than x = x + ..., but today I have realized it is not true when operating with mutable objects. In Python 3.3 or 2.7 IDLE (Windows) compare: >>> a = [3] >>> b = a >>> a = a + [1] >>> b [3] and >>> a = [3] >>> b = a >>> a += [1] >>> b [3, 1] Is this behaviour explained in the Python documentation? Thanking you in advance, Bartolomé Sintes
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
x += ... is not the same than x = x + ... if x is mutable bartolome.sintes@gmail.com - 2013-03-20 07:17 -0700
Re: x += ... is not the same than x = x + ... if x is mutable Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2013-03-20 16:26 +0200
Re: x += ... is not the same than x = x + ... if x is mutable Nobody <nobody@nowhere.com> - 2013-03-21 04:27 +0000
Re: x += ... is not the same than x = x + ... if x is mutable "Colin J. Williams" <cjw@ncf.ca> - 2013-03-21 08:35 -0400
Re: x += ... is not the same than x = x + ... if x is mutable Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-03-21 12:39 +0000
csiph-web