[Tutor] Logging exceptions, but getting stderr output instead

Alex Hall ahall at autodist.com
Wed May 25 15:44:28 EDT 2016


You're not missing anything; I wasn't clear. I wasn't sure if raise or
sys.exit(1) were the preferred ways, or if there was some other way I
didn't know about. I've never had to force a script to halt before, at
least not one I mean to schedule to run on its own once a day, so wanted to
check that those are indeed the recommended ways.

On Wed, May 25, 2016 at 3:37 PM, Alan Gauld via Tutor <tutor at python.org>
wrote:

> On 25/05/16 19:11, Alex Hall wrote:
>
> > As a quick aside, is there an easy way to halt script execution for some
> > exceptions? Right now, catching them means that execution continues, but
> I
> > sometimes want to log the problem and then abort the script, as the error
> > means it shouldn't continue. Thanks.
>
> I'm not sure what the issue is here.
> Can't you just exit in the normal fashion using
>
> sys.exit()
> or
> raise SystemExit?
>
> I feel I must be missing something?
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>



-- 
Alex Hall
Automatic Distributors, IT department
ahall at autodist.com


More information about the Tutor mailing list