On this page
pwd.getpwuid
Prev: pwd.getpwnam | Up: pwd | Next: pwd.struct_passwd
Rel: pwd.getpwall, pwd.getpwnam, pwd.struct_passwd
Ref: docs.python.org — pwd.getpwuid
Tags: #public #python3 #stdlib #pwd
Import
import pwd
from pwd import getpwuid
Signature & Overview
pwd.getpwuid(uidobj, /)
Return the password database entry for the given numeric user ID.
Usage
import os, pwd
entry = pwd.getpwuid(os.getuid())
assert entry.pw_uid == os.getuid() and len(entry.pw_dir) > 0
Gotchas
- Unix-only: Catch
KeyErrorfor unmapped container UIDs.
REPL Inspect
from pwd import getpwuid
help(getpwuid)
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/getpwnam 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