In article <[EMAIL PROTECTED]>,
Tim Roberts  <[EMAIL PROTECTED]> wrote:
>
>One thing that can be helpful in situations like this is to remember that
>+= in Python isn't quite as "special" as it is in C.  So,
>
>  f() += [4]
>
>is the same as
>
>  f() = f() + [4]
>
>and I think you can see why that is a problem.

Actually, it's not quite the same as the expansion, either:

>>> a=[1]
>>> b=a
>>> a+=[2]
>>> a is b
1
>>> a = a + [3]
>>> a is b
0
>>> a
[1, 2, 3]
>>> b
[1, 2]
-- 
Aahz ([EMAIL PROTECTED])           <*>         http://www.pythoncraft.com/

"19. A language that doesn't affect the way you think about programming,
is not worth knowing."  --Alan Perlis
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to