Re: Repeat an exception

2010-02-04 Thread Stephen Hansen
On Thu, Feb 4, 2010 at 4:59 AM, Jean-Michel Pichavant < jeanmic...@sequans.com> wrote: > What the hell is this 'for else' loop !! :D First time I see this statement > for years. > I'd never thought I'd still learn something that basic. > Its one of the least used constructs in Python, I think, an

Re: Repeat an exception

2010-02-04 Thread MRAB
Jean-Michel Pichavant wrote: MRAB wrote: In other words: for attempt in range(2): try: spanish_field = translate(english_field, lang_to='es', lang_from='en') break except TranslationError: pass else: # Didn't break out of the loop, therefore not successful.

Re: Repeat an exception

2010-02-04 Thread Jean-Michel Pichavant
MRAB wrote: In other words: for attempt in range(2): try: spanish_field = translate(english_field, lang_to='es', lang_from='en') break except TranslationError: pass else: # Didn't break out of the loop, therefore not successful. print "Translation failed

Re: Repeat an exception

2010-02-03 Thread Alf P. Steinbach
* MRAB: Alf P. Steinbach wrote: * mf: I'm translating a db from english to spanish with the Google translator API. The problem is when a TranslationError occurs(usually because of connection problems). I can except the first one, but I don't know how to except again. I "solved" the problem by s

Re: Repeat an exception

2010-02-03 Thread MRAB
Alf P. Steinbach wrote: * mf: I'm translating a db from english to spanish with the Google translator API. The problem is when a TranslationError occurs(usually because of connection problems). I can except the first one, but I don't know how to except again. I "solved" the problem by saving tem

Re: Repeat an exception

2010-02-03 Thread Alf P. Steinbach
* mf: I'm translating a db from english to spanish with the Google translator API. The problem is when a TranslationError occurs(usually because of connection problems). I can except the first one, but I don't know how to except again. I "solved" the problem by saving temp db's and then joining t