[Python-ideas] Retrying EAFP without DRY

Paul Moore p.f.moore at gmail.com
Sat Jan 21 12:46:19 CET 2012

On 21 January 2012 07:47, Steven D'Aprano <steve at pearwood.info> wrote:
> This sounds like retry should be a flow-control statement, like continue or
> break, not a block. E.g.:
> try:
>    something()
> except ValueError:
>    if condition: retry
>    else: raise
> "retry" will jump back to the start of the try block -- a limited form of
> GOTO, with all the pros and cons of this.

That's the way I would interpret a "retry" statement - and it's
nothing like the OP's proposal as far as I can see (where retry
introduces a suite).

I'd be -1 on a retry keyword that worked any way other than this
(simply because this is "clearly" the most obvious interpretation).
Whether a retry statement is worth having at all, though, is something
I'm not sure of - I'd like to see some real-world use cases first.
I've never encountered the need for it myself. And I can't honestly
imagine why the while True...try...break" idiom would ever not be


More information about the Python-ideas mailing list