OS routines for Mac, NT, or Posix depending on what system we're on.
Programs that import and use 'os' stand a better chance of being
portable between different platforms. Of course, they must then
only use functions that are defined by all platforms (e.g., unlink
and opendir), and leave all pathname manipulation to os.path
(e.g., split and join).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
abort()
Abort the interpreter immediately. |
|
|
|
|
access(path,
mode)
Use the real uid/gid to test for access to a path. |
|
|
|
|
chdir(path)
Change the current working directory to the specified path. |
|
|
|
|
chmod(path,
mode)
Change the access permissions of a file. |
|
|
|
|
close(fd)
Close a file descriptor (for low level IO). |
|
|
|
|
dup(fd)
Return a duplicate of a file descriptor. |
|
|
|
|
dup2(old_fd,
new_fd)
Duplicate file descriptor. |
|
|
|
|
execl(file,
*args)
Execute the executable file with argument list args, replacing the
current process. |
source code
|
|
|
|
execle(file,
env,
*args)
Execute the executable file with argument list args and
environment env, replacing the current process. |
source code
|
|
|
|
execlp(file,
*args)
Execute the executable file (which is searched for along $PATH)
with argument list args, replacing the current process. |
source code
|
|
|
|
execlpe(file,
env,
*args)
Execute the executable file (which is searched for along $PATH)
with argument list args and environment env, replacing the current
process. |
source code
|
|
|
|
execv(path,
args)
Execute an executable path with arguments, replacing current process. |
|
|
|
|
execve(path,
args,
env)
Execute a path with arguments and environment, replacing current process. |
|
|
|
|
execvp(file,
args)
Execute the executable file (which is searched for along $PATH)
with argument list args, replacing the current process. |
source code
|
|
|
|
execvpe(file,
args,
env)
Execute the executable file (which is searched for along $PATH)
with argument list args and environment env , replacing the
current process. |
source code
|
|
|
|
fdopen(fd,
mode='r' ,
bufsize=...)
Return an open file object connected to a file descriptor. |
|
|
|
|
fstat(fd)
Like stat(), but for an open file descriptor. |
|
|
|
|
fsync(fildes)
force write of file with filedescriptor to disk. |
|
|
|
|
getcwd()
Return a string representing the current working directory. |
|
|
|
|
getcwdu()
Return a unicode string representing the current working directory. |
|
|
|
|
getenv(key,
default=None)
Get an environment variable, return None if it doesn't exist. |
source code
|
|
|
|
getpid()
Return the current process id |
|
|
|
|
isatty(fd)
Return True if the file descriptor 'fd' is an open file descriptor
connected to the slave end of a terminal. |
|
|
|
|
listdir(path)
Return a list containing the names of the entries in the directory. |
|
|
|
|
lseek(fd,
pos,
how)
Set the current position of a file descriptor. |
|
|
|
|
lstat(path)
Like stat(path), but do not follow symbolic links. |
|
|
|
|
makedirs(path,
mode=0777)
Super-mkdir; create a leaf directory and all intermediate ones. |
source code
|
|
|
|
mkdir(path,
mode=0777)
Create a directory. |
|
|
|
|
open(filename,
flag,
mode=0777)
Open a file (for low level IO). |
|
|
|
|
|
|
|
popen(command,
mode='r' ,
bufsize=...)
Open a pipe to/from a command returning a file object. |
|
|
|
|
|
|
|
|
|
|
|
|
|
putenv(key,
value)
Change or add an environment variable. |
|
|
|
|
read(fd,
buffersize)
Read a file descriptor. |
|
|
|
|
remove(path)
Remove a file (same as unlink(path)). |
|
|
|
|
|
|
|
rename(old,
new)
Rename a file or directory. |
|
|
|
|
renames(old,
new)
Super-rename; create directories as necessary and delete any left
empty. |
source code
|
|
|
|
rmdir(path)
Remove a directory. |
|
|
|
|
spawnl(mode,
file,
*args)
Execute file with arguments from args in a subprocess. |
source code
|
|
|
|
spawnle(mode,
file,
env,
*args)
Execute file with arguments from args in a subprocess with the
supplied environment. |
source code
|
|
|
|
spawnv(mode,
path,
args)
Execute the program 'path' in a new process. |
|
|
|
|
spawnve(mode,
path,
args,
env)
Execute the program 'path' in a new process. |
|
|
|
|
startfile(...)
startfile(filepath [, operation]) - Start a file with its associated
application. |
|
|
|
|
stat(path)
Perform a stat system call on the given path. |
|
|
|
|
stat_float_times(newval=...)
Determine whether os.[lf]stat represents time stamps as float objects. |
|
|
|
|
strerror(code)
Translate an error code to a message string. |
|
|
|
|
system(command)
Execute the command (a string) in a subshell. |
|
|
|
|
tempnam(dir=...,
prefix=...)
Return a unique name for a temporary file. |
|
|
|
|
times()
Return a tuple of floating point numbers indicating process times. |
|
|
|
|
tmpfile()
Create a temporary file with no directory entries. |
|
|
|
|
tmpnam()
Return a unique name for a temporary file. |
|
|
|
|
umask(new_mask)
Set the current numeric umask and return the previous umask. |
|
|
|
|
unlink(path)
Remove a file (same as remove(path)). |
|
|
|
|
|
|
|
urandom(n)
Return a string of n random bytes suitable for cryptographic use. |
|
|
|
|
utime(...)
utime(path, (atime, mtime))
utime(path, None) |
|
|
|
|
waitpid(pid,
options)
Wait for completion of a given process. |
|
|
|
|
walk(top,
topdown=True,
onerror=None)
Directory tree generator. |
source code
|
|
|
|
write(fd,
string)
Write a string to a file descriptor. |
|
|