Back to module index
Go to module by name
pwd
This module provides access to the Unix password database.
It is available on all Unix versions.
Password database entries are reported as 7-tuples containing the following
items from the password database (see `<pwd.h>'), in order:
pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell.
The uid and gid items are integers, all others are strings. An
exception is raised if the entry asked for cannot be found.
Classes
struct_passwd
pwd.struct_passwd: Results from getpw*() routines.
This object may be accessed either as a tuple of
(pw_name,pw_passwd,pw_uid,pw_gid,pw_gecos,pw_dir,pw_shell)
or via the object attributes as named in the above tuple.
count(self, value, /)
Return number of occurrences of value.
index(self, value, start=0, stop=9223372036854775807, /)
Return first index of value.
Raises ValueError if the value is not present.
n_fields = 7
n_sequence_fields = 7
n_unnamed_fields = 0
pw_dir = <member 'pw_dir' of 'pwd.struct_passwd' objects>
home directory
pw_gecos = <member 'pw_gecos' of 'pwd.struct_passwd' objects>
real name
pw_gid = <member 'pw_gid' of 'pwd.struct_passwd' objects>
group id
pw_name = <member 'pw_name' of 'pwd.struct_passwd' objects>
user name
pw_passwd = <member 'pw_passwd' of 'pwd.struct_passwd' objects>
password
pw_shell = <member 'pw_shell' of 'pwd.struct_passwd' objects>
shell program
pw_uid = <member 'pw_uid' of 'pwd.struct_passwd' objects>
user id
Functions
getpwall
getpwall()
Return a list of all available password database entries, in arbitrary order.
See help(pwd) for more on password database entries.
getpwnam
getpwnam(name, /)
Return the password database entry for the given user name.
See `help(pwd)` for more on password database entries.
getpwuid
getpwuid(uidobj, /)
Return the password database entry for the given numeric user ID.
See `help(pwd)` for more on password database entries.