Last active
February 5, 2024 19:50
-
-
Save roskakori/4572921 to your computer and use it in GitHub Desktop.
Python OS error codes with symbolic name and human readable error message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Print a list of possible Python OS error codes together with the symbolic | |
# name in `errno` and the related human readable error message. The output | |
# uses Trac Wiki syntax so it can be copied and pasted in a Wiki document | |
# for later reference. | |
# | |
# The output depends on platform and language settings. | |
import errno | |
import os | |
print('||=code =||=symbol =||=message =||') | |
for number in sorted(errno.errorcode.keys()): | |
symbol = errno.errorcode[number] | |
message = os.strerror(number) | |
print('||%d||%s||%s||' % (number, symbol, message)) |
@tiptonnet Concerning your error:
AttributeError: 'module' object has no attribute 'strerror'
The code still works fine with Python 3.11, and strerror
is still part of the standard os
package. It seems you are importing some other module under the name os
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
||=code =||=symbol =||=message =||
Traceback (most recent call last):
File "", line 655, in
File "", line 292, in GetErrorCode
AttributeError: 'module' object has no attribute 'strerror'