"+=" does not work correct all alogn

Olive diolu at bigfoot.com
Thu Jan 19 13:19:50 EST 2012


On Wed, 18 Jan 2012 09:52:55 +0000 (GMT)
Wilfried Falk <w_h_falk at yahoo.de> wrote:

> Hello Pythons,
>  
> attached to this email is a pdf-file which shows, that  "+=" does not
> work well all along. Mybe somebody of you is able to explain my
> observations in this respect. I will be glad about an answer. Best
> regards Wilfried

I am not sure I understand your first question. For the second this is
explained here:
http://docs.python.org/tutorial/controlflow.html#default-argument-values

In the first case, you create a new list from the empty list at each
call. In the second case, you modify the argument in place and it is
not reevaluated between calls.

Olive
 




More information about the Python-list mailing list