[Python-ideas] Retrying EAFP without DRY

Mike Meyer mwm at mired.org
Wed Jan 25 04:22:30 CET 2012


On Tue, 24 Jan 2012 21:53:49 -0500
Vince <vince.vinet at gmail.com> wrote:

> On Tue, Jan 24, 2012 at 8:19 PM, Mike Meyer <mwm at mired.org> wrote:
> > Exception handling and retrying the code that caused the exception are
> > part of the same concept. There is value in being able to express that
> > concept directly with a single construct.
> 
> It seems to me that combining looping and exception handling in the
> same construct makes code harder to read. When you come across any
> looping construct, you know immediately that the following block could
> occur any number of times, depending on the line where the construct
> starts. In the case of try/except/retry, it may come as a surprise that the
> block can actually repeat.

Except the block in the try *doesn't* repeat. That block is only
executed once. It may be *started* multiple times if there are
exceptional conditions, but once it finishes executing, it's
over. That's sort of the point.

      <mike
-- 
Mike Meyer <mwm at mired.org>		http://www.mired.org/
Independent Software developer/SCM consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org



More information about the Python-ideas mailing list