[Edu-sig] class notes (post facto)

Vern Ceder vceder at canterburyschool.org
Wed Jul 14 15:26:28 CEST 2010


Litvin wrote:
> At 11:16 PM 7/13/2010, Vern Ceder wrote:
> Actually this behavior has been in Python since augmented assignments 
> were introduced in version 2.0. The official wording on this (buried in 
> the language reference) is (2.7 version, emphasis mine):
> 
> Vern,
> 
> I was comparing Python 3 with 2.5; the latter doesn't seem to do += for 
> lists in place.
> Gary Litvin
> 
According to the documentation it does. The documentation has pretty 
much the same wording (see 
http://docs.python.org/release/2.5/ref/augassign.html). I just tried it 
with 2.5.2 and I got:

Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> a = [1,2]
 >>> b = [3,4]
 >>> c = a
 >>> a += b
 >>> c
[1, 2, 3, 4]
 >>>

So yeah, Python does += in place for all versions starting with 2.0.

Cheers,
Vern


-- 
This time for sure!
    -Bullwinkle J. Moose
-----------------------------
Vern Ceder, Director of Technology
Canterbury School, 3210 Smith Road, Ft Wayne, IN 46804
vceder at canterburyschool.org; 260-436-0746; FAX: 260-436-5137

The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW


More information about the Edu-sig mailing list