getpass.getuser()
getpass.getuser() is a Python function in the Getpass Module category. Returns the current user's login name. The syntax is getpass.getuser(). Returns: Username string. A typical example: getpass.getuser() # "admin" or "username". A close sibling is getpass.getpass(), which prompts the user for a password without echoing the input. More about this category: Password input — getpass, getuser. Related Getpass Module entries: getpass.getpass(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try getpass.getuser() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.