I don't know why this is rocket science but I cannot find any way to get just the error number in the exception handler. All the examples show how to get the text but not the error number. The documentation web server seems to be down.
except PermissionError as e:
print(????error number??????)
Can someone save me from this frustration? TIA.
I thought all exceptions had the same format. Based on your reply I am guessing that is not true. When I print e, I get this:
[Errno 13] Permission denied
Depending on the permission error the number is different but the format is the same. I tried parsing 'e' but it is not just a string so I could not come up with a way to extract it. I tried using various applications of 'split' but the result is always something odd that is not in the printed string (I get things like '[' and ''', etc)
After some test programming I figured it out 'e' is a PermissionsError class in this case. It contains an attribute named 'errno'. I now understand e will be a specific exception class each of which will have its own attributes. I guess if the documentation web site was up, I'd have been able to determine that. Thanks anyway.