I wish that [].append(x) returned [x]
Carsten Haese
carsten at uniqsys.com
Tue May 1 17:12:42 EDT 2007
On Tue, 2007-05-01 at 14:00 -0700, Paul McGuire wrote:
> On May 1, 3:45 pm, Tobiah <t... at tobiah.org> wrote:
> > I wanted to do:
> >
> > query = "query text" % tuple(rec[1:-1].append(extra))
> >
> > but the append() method returns none, so I did this:
> >
> > fields = rec[1:-1]
> > fields.append(extra)
> > query = "query text" % tuple(fields)
>
> query = "query text" % tuple(rec[1:-1] + [extra])
>
> should work.
In addition to the above good advice, in case you are submitting a query
to a DB-API compliant SQL database, you should use query parameters
instead of building the query with string substitution.
If you aren't querying an SQL database, never mind.
-Carsten
More information about the Python-list
mailing list