

This module represents generic operating system functionality. This module is especially important if you want to make your programs platform-independent i.e. it allows the program to be written such that it will run on Linux as well as Windows without any problems and without requiring changes. An example of this is using theos.sep variable instead of the operation system-specific path separator.
Some of the more useful parts of theos module are listed below Most of them are self-explanatory.• The os.name string specifies which platform you are using, such as 'nt' for Windows and 'posix' for Linux/Unix users.
• Theos.getcwd() function gets the current working directory i.e. the path of the directory from which the curent Python script is working.
• Theos.getenv() andos.putenv() functions are used to get and set environment variables respectively.
• Theos.listdir() function returns the name of all files and directories in the specified directory.
• Theos.remove() function is used to delete a file.
• Theos.system() function is used to run a shell command.
• Theos.path.split() function returns the directory name and file name of the path.
>>> os.path.split('/home/swaroop/byte/code/poem.txt') ('/home/swaroop/byte/code', 'poem.txt')
• Theos.path.isfile() and theos.path.isdir() functions check if the given path refers to a file or directory respectively. Similarly, theos.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 usehelp(sys), etc. as well.