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
caught:
import errno
paths = ["here", "there", "somewhere else"]
for location in paths:
filename = os.path.join(location, "prefs.ini")
try:
f = open(filename)
except IOError as e:
if e.errno != errno.ENOENT: # File not found.
raise
In Python 3.3:
try:
f = open(filename)
except FileNotFound:
pass
But not all errnos have special OSError subclasses.
--
http://mail.python.org/mailman/listinfo/python-list