On this page
getpass.getuser
Prev: getpass.GetPassWarning | Up: getpass
Rel: getpass.getpass, getpass.GetPassWarning
Ref: docs.python.org — getpass.getuser
Tags: #public #python3 #stdlib #getpass
Import
import getpass
from getpass import getuser
Signature & Overview
getpass.getuser()
Get the username from the environment or password database.
Usage
import getpass
user = getpass.getuser()
assert isinstance(user, str) and len(user) > 0
Gotchas
- Checks
LOGNAME,USER,LNAME,USERNAMEenv vars first: Easy to spoof in environment variables—don't usegetuser()for security authorization.
REPL Inspect
from getpass import getuser
help(getuser)
Linked from
Related notes
- tuts/python3/stdlib_module/getpass/getpass Linked here; links to this page; shared tags: #getpass, #stdlib
- tuts/python3/stdlib_module/getpass/GetPassWarning Linked here; links to this page; shared tags: #getpass, #stdlib
- tuts/python3/stdlib_module/getpass 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
- tuts/c/stdlib/ctype/isdigit shared tags: #stdlib