This module represents operating system specific functionality. This module is especially important if you want to make your programs platform-independent i.e. it should run on Linux as well as Windows without any problems and without requiring changes. An example is using the os.sep string instead of '\\' path separator in Windows, the '/' path separator in Linux or ':' path separator in Mac.
Some of the more useful parts of the os module are listed below. Most of them are self-explanatory.
The os.name string specifies which platform you are using. If you are using Windows, it will say 'nt'. If you are using Linux or BSD, it will say 'posix'. If you are using the Jython interpreter instead of the CPython interpreter, it will say 'java'.
The os.getcwd() function returns the current working directory i.e. the name of the directory from which the current Python script is running.
The os.getenv() and os.putenv() functions are used to get and set environment variables.
The os.listdir() function returns the name of all files and directories in the specified directory.
The os.remove() function is used to delete a file.
The os.system() function is used to run a shell command.
The os.linesep string gives the line terminator used in the current platform. For example, Windows uses '\r\n', Linux uses '\n' and Mac uses '\r'.
The os.path.split() function returns the directory name and file name of the path.
>>> os.path.split('/home/swaroop/poem.txt') ('/home/swaroop', 'poem.txt')
The os.path.isfile() and the os.path.isdir() functions check if the given path refers to a file or directory respectively. Similarly, the os.path.exists() function is used to check if a given path actually exists.
You can explore the Python Standard Documentation for more details on these functions and variables. You can use the help() as well.