The variables and methods in the
allow you to interact with files and directories. In most
cases the names and functionalities are the same as the
equivalent C language functions, so refer to Kernighan and
Ritchie, The C Programming Language,
second edition, or the equivalent for more details.
Change the current working directory to that given by
Change the permissions for pathname
. See module
stat, below, for symbolic constants to be used in
Change the owner of pathname
to user id
and group id
A dictionary whose keys are the names of all currently defined environmental variables, and whose values are the values of those variables.
The exception raised for errors in this module.
Replace the current process with a new process executing
the file at pathname
is a list of the strings to be passed to the
new process as command line arguments.
execv(), but you supply a dictionary
defines the environmental variables for the new process.
Exit the current process and return status code
. This method
should be used only by the child process after a
fork(); normally you should use
Fork a child process. In the child process, this
0; in the parent, it
returns the child's process ID.
Returns the current working directory name as a string.
Returns the effective group ID.
Returns the effective user ID.
Returns the current process's group ID. To decode
group IDs, see the
grp standard module.
Returns the current process's process ID.
Returns the parent process's PID (process ID).
Returns the current process's user ID. To decode
user IDs, see the
pwd standard module.
to the process whose process ID is
Create a hard link to
and call the link
Return a list of the names of the files in the directory
whose pathname is
. This list will never contain the special
the current and parent directories. The entries may not
be in any particular order.
stat(), but if
is a link, you will get the
status tuple for the link itself, rather than the file
it points at.
mkdir(), but will also
create any intermediate directories between existing
directories and the desired new directory.
Create a directory at pathname
. You may optionally specify
; see module
stat below for the interpretation of
Create a named pipe with name
and open mode
. The server
side of the pipe will open it for reading, and the
client side for writing. This function does not
actually open the fifo, it just creates the rendezvous
Renice (change the priority) of the current process by
its current priority.
pathname to a soft (symbolic) link, this function
returns the pathname to which that link points.
Removes the file with pathname
, as in the Unix
rm command. Raises
remove(), but also removes
any other parent directory in the path that has no
Remove the directory at path
Return a status tuple describing the file or directory
. See module
stat, below, for the
interpretation of a status tuple. If
is a link, you
will get the status tuple of the file to which
Create a symbolic link to path
, and call the link
Execute the command in string
as a sub-shell. Returns the
exit status of the process.
Returns a tuple of statistics about the current
process's elapsed time. This tuple has the form
is user time,
is system time,
are user and
system time including all child processes, and
is elapsed real
time. All values are in seconds as floats.
Returns a new, open temporary file, with update mode
"w+b". This file will not appear in any
directory, and will disappear when it is no longer in
Sets the “umask” that determines the default permissions for newly created files. Returns the previous value. Each bit set in the umask corresponds to a permission that is not granted by default.
Returns a tuple of strings descriping the operating
is the name of the operating system,
is the name of the processor (node) where you are running,
is the operating system's version number,
is the major version, and
describes the type of processor.
Return a string of
random bytes. These bytes should be
sufficiently random for use in cryptographic
argument must be a tuple
epoch times. For pathname
, set the last access time to
last modification to
Wait for the termination of a child process. Returns a
is the child's
process ID and
is its exit status.
wait(), but it waits for the process
whose ID is
. The option value
specifies what to do if the child is still
is 0, you wait for the child to terminate. Use a
os.WNOHANG if you don't want to