[Tutor] How much in a "try" block?

leam hall leamhall at gmail.com
Fri Aug 23 13:37:12 CEST 2013


Well, maybe I'm looking at the wrong construct. The script needs to open up
one file that will be on the machine. It will open up other files given as
command line arguments and open files to write to. It should fail
gracefully if it cannot open the files to be read or written. The community
that will use the script has varying levels of scripting but not hordes of
Python. I'd prefer to fail with an explanation so they could fix the issue
and not just blame the script.

Leam



On Fri, Aug 23, 2013 at 6:55 AM, Chris Down <chris at chrisdown.name> wrote:

> On 2013-08-23 01:30, Alan Gauld wrote:
> > Unless you really only want g(x) executed if there is no MyError
> exception
> > but want h(x) executed regardless.
>
> I've had that situation a few times before when using the logic "try this,
> or
> fall back to this if it doesn't work".
>
> > I'm curious, how often do others use the try/else combination?
>
> Rarely. I think I've only used it twice in recent memory.
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Mind on a Mission <http://leamhall.blogspot.com/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130823/ad7f2358/attachment.html>


More information about the Tutor mailing list