canonical file access pattern?
hjwidmaier at web.de
Wed Dec 31 18:28:49 CET 2003
Am Wed, 31 Dec 2003 14:51:01 +0000 schrieb John J. Lee:
> If that were true, why did exceptions get invented? If you don't need
> to do something different in all those except: clauses, then don't put
> them in.
One thing I need is to create an informative and useful error message
> As you know, the nice thing about exceptions is that you're
> allowed to handle them in sensible places, so typical usage is like
[handling exceptions in the caller]
> Shock, horror, where's the except IOError:, you ask?! It's in the
> calling function, of course.
Hmm. The farther away from the actual point of error you catch it, the
harder it is to tell exactly what happened and to redo/work around it.
> Also, if you want to catch both OSError and IOError, note that
> EnvironmentError is their common base class.
Good tip! I didn't know that before.
More information about the Python-list