While loop

Fab86 fabien.hall at gmail.com
Thu Mar 5 13:50:40 EST 2009


On Mar 5, 5:49 pm, Fab86 <fabien.h... at gmail.com> wrote:
> On Mar 5, 5:23 pm, Marco Mariani <ma... at sferacarta.com> wrote:
>
>
>
> > Fab86 wrote:
> > > Is it possible to get the program to catch the exception, wait 10
> > > seconds, then carry of from where it was rather than starting again?
>
> > something like this? probably works in PASCAL as well :)
>
> > > i=0
> > > while i < len(stuff):
> > >    try:
> > >       do_with(stuff[i])
> > >    except SomeError:
> > >       sleep(10)
> > >       continue
> > >    i+=1
>
> using sleep and then continue just makes the search start from the
> first search term like before.. Would it be easier to understand if I
> posted sections of my code?
>
> i = 0
> k = open('blah', 'w')
> domains = ["au", "ca", "nl", "be", "...]
> srch = WebSearch(app_id=YahooKey)
>
> while i<200:
>     try:
>         for domain in domains:
>             srch.query = "test site:.%s" % domain
>             res = srch.parse_results()
>             print >> k, res.total_results_available
>             i = i + 1
>
>     except SearchError:
>
> (I currently close then reopen document here then restart i to 0)
>
> Any ideas?

All sorted now, thanks.



More information about the Python-list mailing list