Where's the List?

Victor Subervi victorsubervi at gmail.com
Sun Jun 6 09:22:44 EDT 2010


On Sat, Jun 5, 2010 at 4:52 PM, Stephen Hansen <apt.shansen at gmail.com>wrote:

>
>     cur.execute(sql, [pkg, prodid, tmpTable, quantity] +
> list(option_values))
>
> Or:
>
>    cur.execute(sql, (pkg, prodid, tmpTable, quantity) + option_values)
>
> I removed the explicit conversion-to-tuple in the first, because... you
> don't need to. Execute takes a sequence. It doesn't have to be a tuple. A
> list is fine. In the second one, I just build my first arguments as a tuple
> instead of as a list, and then add option_values to it... You'll just have
> to go up top and do:
>
>     option_values = ()
>
> In both places where you currently use []. As you can't add a list to a
> tuple anymore then a tuple to a list, for the same reasons.
>

Thanks. I always get tripped up on lists and tuples. In fact, just now I
decided to look up the difference again, it's so slight. At any rate, I
deliberately checked my variables using isinstance() and they all checked
out as tuples, so that's why I couldn't figure out where the list was!
Thanks again,
beno
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100606/b8a2dd1d/attachment.html>


More information about the Python-list mailing list