blob: a7424390d4b02f48ff8ca6739c259ba93872412b [file] [log] [blame]
Fred Drake5ac2a071998-12-22 23:37:21 +00001\section{\module{getpass}
Fred Drakeb3a20bc1999-03-12 18:34:21 +00002 --- Portable password input}
Fred Drake5ac2a071998-12-22 23:37:21 +00003
4\declaremodule{standard}{getpass}
Fred Drake5ac2a071998-12-22 23:37:21 +00005\modulesynopsis{Portable reading of passwords and retrieval of the userid.}
Fred Drakeb3a20bc1999-03-12 18:34:21 +00006\moduleauthor{Piers Lauder}{piers@cs.su.oz.au}
7% Windows (& Mac?) support by Guido van Rossum.
8\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
Fred Drake5ac2a071998-12-22 23:37:21 +00009
10
11The \module{getpass} module provides two functions:
12
13
Georg Brandl338ef7d2006-03-31 18:42:16 +000014\begin{funcdesc}{getpass}{\optional{prompt\optional{, stream}}}
Fred Drake5ac2a071998-12-22 23:37:21 +000015 Prompt the user for a password without echoing. The user is
16 prompted using the string \var{prompt}, which defaults to
Georg Brandl338ef7d2006-03-31 18:42:16 +000017 \code{'Password: '}. On \UNIX, the prompt is written to the
18 file-like object \var{stream}, which defaults to
19 \code{sys.stdout} (this argument is ignored on Windows).
20
Fred Drakec37b65e2001-11-28 07:26:15 +000021 Availability: Macintosh, \UNIX, Windows.
George Yoshida5085fe22006-04-30 03:49:56 +000022 \versionchanged[The \var{stream} parameter was added]{2.5}
Fred Drake5ac2a071998-12-22 23:37:21 +000023\end{funcdesc}
24
25
26\begin{funcdesc}{getuser}{}
27 Return the ``login name'' of the user.
Fred Drakec37b65e2001-11-28 07:26:15 +000028 Availability: \UNIX, Windows.
Fred Drake5ac2a071998-12-22 23:37:21 +000029
30 This function checks the environment variables \envvar{LOGNAME},
31 \envvar{USER}, \envvar{LNAME} and \envvar{USERNAME}, in order, and
32 returns the value of the first one which is set to a non-empty
33 string. If none are set, the login name from the password database
Fred Drakeffbe6871999-04-22 21:23:22 +000034 is returned on systems which support the \refmodule{pwd} module,
Fred Drake5ac2a071998-12-22 23:37:21 +000035 otherwise, an exception is raised.
36\end{funcdesc}