Juho Schultz wrote:
> Yves Glodt wrote:
> > Hello,
> >
> > if I do this:
> >
> > for row in sqlsth:
> > ________pkcolumns.append(row[0].strip())
> > ________etc
> >
> 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 don't think this is the same as his original code though. There is an
"etc" there. Your version is cleaner and easier to understand but it
can mean another extra pass to go through the result and if sqlsth is
an iterable, it needs to be saved away before iterating it.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to