Augmented augmented assignment?
Dale Strickland-Clark
dale at riverhall.NOTHANKS.co.uk
Mon Oct 22 18:20:23 EDT 2001
Can someone explain this?
It doesn't seem obvious to me but it's quite handy.
I assume it's something to do with the in-place operation of augmented
assignment but I can't seem to reproduce it using normal assignment.
>>> x = 'spam'
>>> y = []
>>> y = y + x
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
TypeError: can only concatenate list (not "string") to list
>>> y += x
>>> y
['s', 'p', 'a', 'm']
>>>
--
Dale Strickland-Clark
Riverhall Systems Ltd
More information about the Python-list
mailing list