
The os System Module
|
97
popen4(cmd [, bufsize [, mode]])
Like popen3, but ties stdout and stderr to a single output
pipe. Returns the file object’s tuple:
(child_stdin, child_
stdout_and_stderr)
. New in Version 2.0.
See also the
subprocess module in Version 2.4 and later,
which allows you to spawn new processes, connect to their
input/output/error pipes, and obtain their return codes in
other ways.
Environment Tools
These attributes export execution environment and context.
environ
The shell environment variable dictionary. os.
environ['USER']
is the value of variable USER in the shell
(equivalent to
$USER in Unix and %USER% in DOS). Initial-
ized on program startup. Changes made to
os.environ by
key assignment are exported outside Python using a call
to C’s
putenv and are inherited by any processes that are
later spawned in any way, and any linked-in C code.
putenv(varname, value)
Sets the shell environment variable named varname to the
string
value. Affects subprocesses started with system,
popen, spawnv,orfork and execv. Assignment to os.
environ
keys automatically calls putenv (but putenv calls
don’t update
environ).
getcwd()
Returns the current working directory name as a string.
chdir(path)
Changes the current working directory for this process to
path, a directory name string. Future file operations are
relative to the new current working directory.
strerror(code)
Returns an error message corresponding to code ...