[Tutor] short url processor
Nick Raptis
airscorp at otenet.gr
Sat May 14 05:30:18 CEST 2011
On 05/14/2011 03:49 AM, ian douglas wrote:
> for i in giant_list:
> if i[0]:
> if i[1]:
> mc.set(i[0], i[1])
>
>
Until Alan comes with a more round answer, I'd suggest something along
the lines of
[mc.set(x, y) for (x, y) in giant_list if x and y]
I'm writing this by memory, but check "list comprehension" in the
documentation.
Anyway, there are map, reduce and such functions in python, but I think
that in python 3.x you have to import them.
Now, the real question would be, can you use the cursor as an iterator
(but without hitting the database for each new record)?
Then you can skip the worst part of loading all the values in giant_list.
Just an idea for Alan and the others to answer.
Nick
More information about the Tutor
mailing list