append to non-existing list

Roy Smith roy at
Wed Nov 9 14:52:30 CET 2005

In article <mailman.353.1131543337.18701.python-list at>,
 Yves Glodt <y.glodt at> wrote:

> > You mean you want to type "pkcolumns" only once to keep your code short?
> > Would something like this be useful?
> > 
> > pkcolumns = [row.strip() for row in sqlsth]
> I will look into this, maybe it's what I need, thanks!

The list comprehension format described above is handy and compact, and 
there's no reason you shouldn't use it when appropriate.  That being said, 
compactness should not itself be a goal.

Writing clear and easy to understand code is much more important than 
reducing the number of lines.  Sometimes you get both at the same time, but 
not always.

More information about the Python-list mailing list