Errno Module ============ .. toctree:: :maxdepth: 1 Indices and tables ------------------ * :ref:`genindex` * :ref:`modindex` * :ref:`search` Introduction ------------ It can be quite useful to have a standardized error number as part of an exception, or as the return value from your function or application. The :py:mod:`errno` module compliments this goal. .. _section_heading-Error_Codes: Error Codes ----------- The :py:mod:`errno` module defines over 100 constants to describe various erroneous situations. For example * :py:data:`errno.EPERM` - Operation not permitted * :py:data:`errno.ENOENT` - No such file or directory * :py:data:`errno.EIO` - IO error * :py:data:`errno.EINVAL` - Invalid argument * :py:data:`errno.ENOSYS` - Function not implemented .. _section_heading-Error_Mapping: Error Mapping ------------- There are two types of mapping with error values that can be performed: * Using the :py:data:`errno.errorcode` dictionary, you can go from error number, to the name of the constant that is defined for it. For example: >>> import errno >>> errno.errorcode[1] 'EPERM' * Using :py:func:`os.strerror`, you can go from error constant, to a string error message. For example: >>> import errno >>> import os >>> os.strerror(errno.EPERM) 'Operation not permitted'