These functions and data items provide information and operate on the current process and user.
environ['HOME']
is the pathname of your home directory (on some
platforms), and is equivalent to getenv("HOME")
in C.
This mapping is captured the first time the os module is
imported, typically during Python startup as part of processing
site.py. Changes to the environment made after this time are
not reflected in os.environ
, except for changes made by modifying
os.environ
directly.
If the platform supports the putenv() function, this
mapping may be used to modify the environment as well as query the
environment. putenv() will be called automatically when
the mapping is modified.
Note:
Calling putenv() directly does not change
os.environ
, so it's better to modify os.environ
.
Note:
On some platforms, including FreeBSD and Mac OS X, setting
environ
may cause memory leaks. Refer to the system documentation
for putenv().
If putenv() is not provided, this mapping may be passed to the appropriate process-creation functions to cause child processes to use a modified environment.
path) |
fd) |
) |
) |
) |
) |
) |
) |
) |
pwd.getpwuid(os.getuid())[0]
to get the login name
of the currently effective user ID.
Availability: Unix.
pid) |
) |
) |
) |
) |
varname[, value]) |
None
.
Availability: most flavors of Unix, Windows.
varname, value) |
Note:
On some platforms, including FreeBSD and Mac OS X,
setting environ
may cause memory leaks.
Refer to the system documentation for putenv.
When putenv() is
supported, assignments to items in os.environ
are automatically
translated into corresponding calls to putenv(); however,
calls to putenv() don't update os.environ
, so it is
actually preferable to assign to items of os.environ
.
egid) |
euid) |
gid) |
groups) |
) |
pid, pgrp) |
ruid, euid) |
rgid, egid) |
pid) |
) |
uid) |
code) |
mask) |
) |
(sysname, nodename, release, version,
machine)
. Some systems truncate the nodename to 8
characters or to the leading component; a better way to get the
hostname is socket.gethostname()
or even
socket.gethostbyaddr(socket.gethostname())
.
Availability: recent flavors of Unix.
See About this document... for information on suggesting changes.