[Python-ideas] Retrying EAFP without DRY

Paul Moore p.f.moore at gmail.com
Tue Jan 24 10:47:38 CET 2012

On 24 January 2012 03:18, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> Jim Jewett writes:
>  > So it doesn't seem like a loop because you hope to do it only once?
> With s/hope/expect/, that hits the nail on the head.
> I don't think syntax can express that cleanly, but I can't help
> thinking it's of good thing if somebody like Mike tries to find a way.
> He might succeed!

If Python was like Haskell or Lisp, where you can define your own
control structures, and this was a proposal to add a new control
structure to the stdlib, I'd be fine with it. It *is* a somewhat
unusual case, and from some people's viewpoint, certainly, the
construct is not really a loop. So having "from exception_handling
import retry" would be plausible.

But Python doesn't have user defined control structures, by design,
and indeed takes a strongly minimalist position on adding control
structures - we don't even have do...while (yet), as Nick has pointed
out. So in that context, I believe that this case is not sufficiently
special, and the "not a loop" viewpoint is not sufficiently universal,
to warrant a language change.

Certainly, I wouldn't argue that this should be part of the language
before do...while (which is more generally useful) gets in.


More information about the Python-ideas mailing list