Suggestion for (re)try statement



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
.



Relevant Pages