Newbie needs Help

John Machin sjmachin at lexicon.net
Thu Aug 17 00:18:31 EDT 2006


johnzen... at gmail.com wrote:
> Also, it may be easier to use string interpolation, as in:
>
> return "INSERT INTO statecode (state, name) VALUES ('%(state)s',
> '%(name)s')" % insert_dict
>
> ...after all necessary escaping, of course.
>

Excuse me!? "statecode" needs to come from the first argument. Likewise
the words "state" and "name" are *variables*. The OP has a gazillion
other tables to process -- are you suggesting he should type in a
gazillion different hard-coded return statements when he's already on
the right track and just needs a bit of help with dict.keys() and
dict.values()?




More information about the Python-list mailing list