[Python-ideas] Retrying EAFP without DRY
Bruce Leban
bruce at leapyear.org
Sat Jan 21 02:40:15 CET 2012
More information about the Python-ideas mailing list
Sat Jan 21 02:40:15 CET 2012
- Previous message: [Python-ideas] Retrying EAFP without DRY
- Next message: [Python-ideas] Retrying EAFP without DRY
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Jan 20, 2012 at 4:36 PM, Mike Meyer <mwm at mired.org> wrote: > A single new keyword/clause, "retry". It has the same syntax as an > "except" clause, can be used anywhere "except" can be used, and can be > intermingled with them in the same try statement. There's probably a > better syntax, but this is easy to describe. > > The behavior change from except is that instead of exiting the "try" > statement when the "retry" clause ends, it restarts the try > clause. In python, this code: > > try: > # try block > except: > # except block > retry: > # retry block > else: > # else block > finally: > # finally block > Can you write this in terms of current Python code? I don't understand exactly when a retry block would be executed. In Eiffel, retry is a statement, not a clause. Analogous to that would be: try: # block except: # block if condition: retry The equivalent of this in current Python is while True: try: # block except: # block if condition: continue # retry break FWIW, if this turns out to be a good idea, an alternate spelling that would not require a new keyword is 'try again'. --- Bruce Follow me: http://www.twitter.com/Vroo http://www.vroospeak.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20120120/e067c101/attachment.html>
- Previous message: [Python-ideas] Retrying EAFP without DRY
- Next message: [Python-ideas] Retrying EAFP without DRY
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list