On this page
pwd.getpwnam
Prev: pwd.getpwall | Up: pwd | Next: pwd.getpwuid
Rel: pwd.getpwall, pwd.getpwuid, pwd.struct_passwd
Ref: docs.python.org — pwd.getpwnam
Tags: #public #python3 #stdlib #pwd
Import
import pwd
from pwd import getpwnam
Signature & Overview
pwd.getpwnam(name, /)
Return the password database entry for the given user name.
Usage
import os, pwd
name = pwd.getpwuid(os.getuid()).pw_name
assert pwd.getpwnam(name).pw_uid == os.getuid()
Gotchas
- Raises
KeyErrorif username is not found.
REPL Inspect
from pwd import getpwnam
help(getpwnam)
Linked from
Related notes
- tuts/python3/stdlib_module/pwd/getpwall Linked here; links to this page; shared tags: #pwd, #stdlib
- tuts/python3/stdlib_module/pwd/getpwuid Linked here; links to this page; shared tags: #pwd, #stdlib
- tuts/python3/stdlib_module/pwd/struct_passwd Linked here; links to this page; shared tags: #pwd, #stdlib
- tuts/python3/stdlib_module/pwd Linked here; links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib
- tuts/c/stdlib/assert/assert shared tags: #stdlib
- tuts/c/stdlib/assert/static_assert shared tags: #stdlib
- tuts/c/stdlib/ctype shared tags: #stdlib
- tuts/c/stdlib/ctype/isalpha shared tags: #stdlib