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

Jonas Bengtsson jonas.b at home.se
Sun Jul 15 04:27:12 EDT 2001


Ok, thanks! I didn't realize that that was possible.

/Jonas B

Fernando Pereira <fcnpereira at home.com> wrote in message news:<140720011910209035%fcnpereira at home.com>...
> 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