a wierd parameter passing behavior

Thomas Güttler guettler at thomas-guettler.de
Wed Jun 4 10:00:06 EDT 2003


Torvo Sollazzo wrote:

> Hi!
> 
> I found a strange parameter passing behavior in Python (v. 2.2.2).
> Look at this piece of code:

[cut]
>     l += [3]

This is like l.append()

>     l = l + [3]

l + [3] creates a new list

I think it is better coding style to use append() than the
plus operator on lists. 

 thomas





More information about the Python-list mailing list