good exampleby using similar techniques for class exceptions in your own codeyou can provide exception sets that are flexible and easily modified python reworks the built-in io and os exception hierarchies it adds new specific exception classes corresponding to common file and system error numbersand groups these and others related to operating system calls under the oserror category superclass former exception names are retained for backward compatibility prior to thisprograms inspect the data attached to the exception instance to see what specific error occurredand possibly reraise others to be propagated (the errno module has names preset to the error codes for convenienceand the error number is available in both the generic tuple as args[ and attribute errno) :\temppy - tryf open('nonesuch txt'except ioerror as vif errno = print('no such file'elseraise no such file or errno nv args[ propagate others this code still works in but with the new classesprograms in and later can be more specific about the exceptions they mean to processand ignore othersc:\temppy - tryf open('nonesuch txt'except filenotfounderrorprint('no such file'no such file for full details on this extension and its classessee the other resources listed earlier default printing and state built-in exceptions also provide default print displays and state retentionwhich is often as much logic as user-defined classes require unless you redefine the constructors your classes inherit from themany constructor arguments you pass to these classes are automatically saved in the instance' args tuple attributeand are automatically displayed when the instance is printed an empty tuple and display string are used if no constructor arguments are passedand single argument displays as itself (not as tuplebuilt-in exception classes