Another Little MySQL Problem

Kushal Kumaran kushal.kumaran at gmail.com
Wed May 26 11:25:51 EDT 2010


On Tue, 2010-05-25 at 14:45 -0400, Victor Subervi wrote:
> Hi;
> I have this code:
> 
>     clientCursor.execute('select ID from %s' % (personalDataTable))
>     upds = [itm[0] for itm in clientCursor]
>     print "<input type='hidden' name='upds' value='%s' />" % upds
> 
> The problem is that the values passed are 1L, 2L.... When I retrieve
> them on the other end and try to convert them to integers, guess what
> happens? So how do I get rid of that "L"?

You could build a list of ints instead of a list of longs, like this:

upds = [int(itm[0]) for itm in clientCursor]

I'm not sure if the result of applying str() on lists is guaranteed not
to change, though.

-- 
regards,
kushal






More information about the Python-list mailing list