What is OSerror in python? | SoloLearn: Learn to code for FREE!


What is OSerror in python?

8/30/2018 5:10:41 PM

Purvi Reddy

4 Answers

New Answer


When using a module's tools, etc, if it has configuration parameters, be sure to hardcode those. I had a lot of those errors pop up after running some code on a Linux machine (that was originally programmed on a Windows machine).


You can check here https://docs.python.org/3/library/exceptions.html


exception OSError¶ This exception is derived from EnvironmentError. It is raised when a function returns a system-related error (not for illegal argument types or other incidental errors). The errno attribute is a numeric error code from errno, and the strerror attribute is the corresponding string, as would be printed by the C function perror(). See the module errno, which contains names for the error codes defined by the underlying operating system. For exceptions that involve a file system path (such as chdir() or unlink()), the exception instance will contain a third attribute,filename, which is the file name passed to the function. Source: docs.python.org


Also note, Python is self-documented (though not to the extent of a website). print(OSError.__doc__) Base class for I/O related errors. help("OSError") Help on class OSError in module builtins: class OSError(Exception): | Base class for I/O related errors. | | Method resolution order: | OSError | Exception | BaseException | object | ...