Awsome Python - chained exceptions
storchaka at gmail.com
Fri Feb 15 19:51:21 CET 2013
On 14.02.13 08:39, Steven D'Aprano wrote:
> Here is one example of using raise to re-raise an exception you have just
> import errno
> paths = ["here", "there", "somewhere else"]
> for location in paths:
> filename = os.path.join(location, "prefs.ini")
> f = open(filename)
> except IOError as e:
> if e.errno != errno.ENOENT: # File not found.
In Python 3.3:
f = open(filename)
But not all errnos have special OSError subclasses.
More information about the Python-list