[Tutor] really basic question..

Alan Gauld alan.gauld at yahoo.co.uk
Sat Aug 5 12:43:36 EDT 2017


On 05/08/17 16:48, bruce wrote:

> redid a search just now. found a bunch of sites that said it's
> doable.. embarrased

Just because its doable doesn't mean you should though...

Bare except clauses can hide a multitude of sins. Unless its
at the top level of your program and you use it to log
any errors that occur its probably a bad idea.

Much better to be as specific as possible and catch only
anticipated errors. Anything else will then cause a crash
and you can investigate the (unanticipated) cause.

Note, you can link multiple error types in a single
except clause

try:...
except Error1:...
except (Error2, Error3, Error4):....

HTH

-- 
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




More information about the Tutor mailing list