[Python-ideas] Retrying EAFP without DRY
Mike Meyer
mwm at mired.org
Tue Jan 24 05:44:27 CET 2012
"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.
Right. Doing it more than once is an exceptional case. And is more exceptional every time through.
That using an LBYL idiom, or simply repeating yourself, means you don't need a loop says to me that it isn't really a loop. Which is why using loop to write it feels wrong.
That I translated into a loop was because the only tools Python has for this is a loop. That no more makes it a loop than map being a function call makes it not a loop.
I'd say that using retry to write what really is a loop (ie - you can't know a maximum number of iterations at compile time) would constitute abuse. A very attractive abuse, at that. Which certainly counts against out.
>He might succeed!
Or someone else will figure it out after I've correctly described the problem.
--
Sent from my Android tablet with K-9 Mail. Please excuse my brevity.
More information about the Python-ideas
mailing list