list[] = var => list.append(var) (phpstyle)

Fernando Pereira fcnpereira at home.com
Sat Jul 14 19:10:22 EDT 2001


In article <4e2ddb70.0107141310.3c7ca355 at posting.google.com>, Jonas
Bengtsson <jonas.b at home.se> wrote:

> I think it should be neet if it would be possible to append a variable
> to a list by just using
> list_var[] = var_to_append
> It works that way in PHP and I think it's nice.
> 
> Any comments?

>>> l = [1, 2]
>>> x = 3
>>> l += [x]
>>> l
[1, 2, 3]

(Python 2.x)

-- F



More information about the Python-list mailing list