Error HandlingSystem-related errors are typically translated into the following
Cause of the error is contained in errno attribute of exception
Example:import os, errno ... try: os.execlp("foo") except OSError,e: if e.errno == errno.ENOENT: print "Program not found. Sorry" elif e.errno == errno.ENOEXEC: print "Program not executable." else: # Some other kind of error |
<<< | O'Reilly OSCON 2000, Advanced Python Programming, Slide 56 July 17, 2000, beazley@cs.uchicago.edu |
>>> |