append to non-existing list

Roy Smith roy at panix.com
Wed Nov 9 14:29:28 CET 2005


Yves Glodt <y.glodt at sitasoftware.lu> wrote:

> My question is: Is there no way to append to a non existing list?

Nope.  The problem (well, part of the problem, anyway) is that when you do:

foo.append (bar)

what's happening is you're calling foo's append method.  If foo doesn't 
already exist, it has no way of knowing what to call.

> I am lazy for declaring it first, IMHO it bloats the code, and (don't 
> know if it's good to say that here) where I come from (php) I was used 
> to not-needing it...

Python is not php.  Nor is it Perl.  Nor it is a whole bunch of other 
things.



More information about the Python-list mailing list