2 python questions!
Laszlo Nagy
gandalf at shopzeus.com
Thu Sep 6 10:41:03 EDT 2007
resist_think at hushmail.com wrote:
> Hi python community!
> First question has to do with threading support. There is the
> following simple case:
> I have a dictionnary that gets it's values -which are url's-from a
> function. Sort of
>
> dictionnary['1'] = "http://www.google.com"
> dictionnary['2'] = "http://www.python.com"
> ....
>
> I need to fill in the dictionnary with some url's. If I do it on
> the simplest way, it would be like:
>
> for i in range(20):
> dictionnary["%s" % i] = get_urls(args)
>
> and wait a long long time till it finishes. Can I do it easily with
> threads, without having to add too much code? Ideal case would be
> if all threads start simultaneously :)
>
Look at thread.start_new_thread here:
http://docs.python.org/lib/module-thread.html
You can call a function in a separate thread, and you do not need to
write a new class.
(I do not like start_new_thread and I would define classes for this, but
you are free to use this feature.)
> Now the second question has to do with images retrieval and
> manipulation. Which libraries do you propose to work with to
> retrieve and resize images from the web?
>
I would use PIL because it is popular, easy to use, available on most
platforms and has few dependencies.
Check out http://www.pythonware.com/products/pil/
Best,
Laszlo
More information about the Python-list
mailing list