append to non-existing list

Yves Glodt y.glodt at
Wed Nov 9 13:46:52 CET 2005


if I do this:

for row in sqlsth:

without a prior:

pkcolumns = [];

I get this error on first iteration:
UnboundLocalError: local variable 'pkcolums' referenced before assignment

I guess that's normal as it's the way python works...?!?

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

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...


More information about the Python-list mailing list