Os
- 1 chdir method of os module in Python The os.chdir() method in Python changes the current working directory of the process. The Python example prints the current working directory and changes it subsequently using os.chdir(), to the $HOME directory of the user and prints it. 16 Nov 2018
- 2 chmod() function of os module in Python The chmod() function of os module in Python changes the file permissions for an existing file. The file is specified by the path parameter and the permissions are specified by the mode parameter. 29 Mar 2023
- 3 copy_file_range() function of os module in Python The copy_file_range() function copies a specified range of bytes from a source file to a destination file wherein both the files reside in the same filesystem. 13 May 2023
- 4 cpu_count of os module in Python The os.cpu_count() method in Python returns the number of processors/cores available in the system. In the Python example provided the program creates a number of threads equal to the number of cores and the main thread waits for the children to complete their execution. 20 Nov 2018
- 5 ctermid() method of os module in Python The Python method os.ctermid() returns the path corresponding to the controlling terminal of the process. The Python example shows that the special file corresponding to the controlling terminal(where the Python program is running) is /dev/tty. 16 Nov 2018
- 6 os.environ - The environment variables mapping in python os.environ in python has the environment variables set on it as a mapping object during the startup of the Python. The example Python program retrieves the $HOME from the os.environ and adds a new environment value called $TestLogPath and prints it on the terminal. 16 Nov 2018
- 7 fchmod() function of os module in Python The fchmod() function of the os module in Python changes the file permissions of a file associated with a file descriptor. The permissions are specified by doing a bitwise OR of one or more permission masks. 30 Mar 2023
- 8 The fdopen() function of os module in Python The fdopen() function of os module in Python creates a file object using an already existing file descriptor. 9 May 2023
- 9 os.fork in Python os.fork implements the system call fork(). When os.fork() is called the process is copied and a child process is created. The Python examples, shows how os.fork() works. 14 Nov 2018
- 10 getcwd() method - Get Current Working Directory in Python using the os module The getcwd() method of the os module in Python, returns the current working directory of the process. The Python example, creates a file in the working directory only by using the file name and prints the whole path. The example also creates a directory and changes the working directory of the process to the newly created directory. 16 Nov 2018
- 11 get_exec_path of os module in Python The os.get_exec_path() method in Python returns the list of paths that will be searched for while launching a process. The Python example gets the list of paths from the default environment of the system and prints them. 20 Nov 2018
- 12 getpgrp() method of os module in Python The getpgrp() method in the os module of Python returns the current process group id the process belongs to. Process groups are used in Unix-like operating systems for inter process communication including termination of orphaned processes. 15 Nov 2018
- 13 getpid in Python The os module of Python provides the getpid() method which returns the process id of the current process.The python examples calls getpid() in a normal scenario as well under a forked scenario. 14 Nov 2018
- 14 getppid in Python os module The getppid() method returns the pid of the parent. The python examples print the pid of the parent, child and grandchild processes and the parent pid at each level. 14 Nov 2018
- 15 getpriority() function of os module in Python The getpriority() retrieves the priority of a process. The priority values range from -20 to +20. Lower the priority value higher the priority i 11 Feb 2023
- 16 os module in Python The os module in Python implements the functionalities that are directly dependent on the operating system. For example creating a file, accessing or adding an environment variable, getting file permissions, getting a process id are all directly dependent on the Operating System. 14 Aug 2019
- 17 The link() function of os module in Python The link() function of os module in Python creates a reference to an existing file. 6 May 2023
- 18 The listdir() function of os module in Python The listdir() function of os module in Python returns the name of the entries present in a directory. 6 May 2023
- 19 makedirs() function of os module in Python The makedirs() function of os module in Python creates a given directory hierarchy and the leaf directory recursively. 13 May 2023
- 20 The mkdir() function of os module in Python The os.mkdir() function creates a directory in the filesystem as specified by the file path. The mkdir() function raises an exception when the directory with same name already exists. 16 May 2023
- 21 os.name The os.name holds the name of the current operating system dependent module loaded by the os module. The value is one of the following:posix and nt. 31 Mar 2021
- 22 open() function of os module in Python The os.open() function opens a file, based on on the flags and modes parameters passed to it and returns a file descriptor. The descriptor can be used for performing low level I/O using function like os.read() and os.write(). 1 May 2023
- 23 readp() function of the os module in Python The readp() function of the os module in Python reads specified number of bytes or less from a given offset. 3 May 2023
- 24 read() function of os module in Python The os.read() function reads the specified number of bytes or less from a file using an open file descriptor and returns a bytes object. 2 May 2023
- 25 The readlink() function of os module in Python The readlink() function returns the string containing the actual file path pointed to by a symbolic link 15 May 2023
- 26 remove() function of os module in Python The remove() function from the os module of Python removes a file as specified by a file path. If the file path is not found a FileNotFoundError exception is raised. 27 Mar 2023
- 27 sendfile() function of os module in Python The sendfile() function copies the contents of one file to another file using their descriptors. In the Python example, both a TCP server and its clients sends files to each other using the sendfile() of the os module. 5 May 2023
- 28 stat() function of os module in Python The function os.stat() provides information about a file which include file mode, inode number, file size in bytes, device id, number of hard links, user id, group id and last modified time. 7 May 2023
- 29 os.supports_bytes_environ The os module has a Boolean flag that supports_bytes_environ. This flag is to indicate whether the environment variables of the operating system can be retrieved as bytes. 2 Apr 2021
- 30 truncate() function of os module in Python Given a file path the os.truncate() function truncates the file contents of a file to the specified length. 4 May 2023
- 31 The umask() function of os module in Python The umask() function of the os module in Python sets the new umask value in a process and returns the old umask value. 25 Feb 2023
- 32 uname() method of os module in Python The python method os.uname() returns system Information including the details of the operating system kernel. The output of the Python example prints the macOS information including the kernel version along with the network node name. 15 Nov 2018
- 33 wait() method of Python os module In Unix, the os.wait() method of Python synchronizes with the child process by waiting for it to complete. The example program creates a child process by calling os.fork() and waits for it to complete by making an os.wait() call. 19 Nov 2018
- 34 The walk() function in Python The function walk() from the os module, provides names of children for a given directory. The containing directory name is also returned for each child. 3 Apr 2021
- 35 The write function of os module in Python The write() function writes given number of bytes to a file using its file descriptor. The function returns number of bytes written to the file. 6 May 2023