How do I get the current value of "errno"

Fredrik Lundh fredrik at
Mon Mar 28 18:26:01 CEST 2005

Steve Juranich wrote:

>I know that there's os.strerror to get the error string, and the errno
> module gives me all of the mappings like 34 -> ERANGE.  But I have yet
> to find out how to check the value of errno in a Python script.

    import os, errno

    except OSError, v:
        print v.errno
        print errno.errorcode[v.errno]
        print os.strerror(v.errno)


More information about the Python-list mailing list