How do I get the current value of "errno"

Fredrik Lundh fredrik at pythonware.com
Mon Mar 28 11:26:01 EST 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

    try:
        os.remove("nisse")
    except OSError, v:
        print v.errno
        print errno.errorcode[v.errno]
        print os.strerror(v.errno)

</F> 






More information about the Python-list mailing list