O'Reilly logo

Python: Essential Reference, Third Edition by David Beazley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

pwd

The pwd module provides access to the UNIX password database.

getpwuid(uid)

Returns the password database entry for a numeric user ID, uid. Returns a password structure with the following attributes:

  • pw_name The login name

  • pw_passwd The encrypted password (optional)

  • pw_uid The numerical user ID

  • pw_gid The numerical group ID

  • pw_gecos The username or comment field

  • pw_dir The user home directory

  • pw_shell The user shell

For backward compatibility, the returned object also behaves like a 7-tuple (pw_name, pw_passwd, pw_uid, pw_gid, pw_gecos, pw_dir, pw_shell). KeyError is raised if the entry cannot be found.

getpwnam(name)

Returns the password database entry for a username.

getpwall()

Returns a list of all available password database entries. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required