Suggestion for (re)try statement

Sori Schwimmer sxn02 at yahoo.com
Thu Oct 27 16:10:39 EDT 2005


Hi,

I think that would be useful to have an improved
version of the "try" statement, as follows:

try(retrys=0,timeout=0):
  # things to try
except:
  # what to do if failed

and having the following semantic:

for i in range(retrys):
  try:
    # things to try
  except:
    if i < retrys:
      i += 1
      sleep(timeout)
    else:
      # what to do if failed
  else:
    break

Of course, "break" may be the last statement in the
"try" branch, and "try"'s "else" may be ommited
completely.

Can't think of a syntax to keep it look like a
statement rather than a function.

Opinions? Is it worth for a PEP?

Sorin


		
__________________________________ 
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.yahoo.com



More information about the Python-list mailing list