all Python 3getpassterm
getpass
module
Reading a password in the terminal without echoing characters, and the name of the current system user.
Syntax
import getpass
getpass.getpass() replaces input() where a password is typed: the input is not shown on screen. When echo cannot be hidden (in an IDE, for instance), the module issues GetPassWarning and reads in the clear. getuser() takes the name from the LOGNAME, USER, LNAME and USERNAME environment variables, so it is unfit for access checks: a variable is easy to fake.
Examples
import getpass
user = getpass.getuser()
print(isinstance(user, str)) # → True
print(user) # → ? имя текущего пользователя
See also
Open in the full glossarydocs.python.orgReport an inaccuracy