blob: da1f9f5807be11e99979078bd29a36ccd47442c3 [file] [log] [blame]
Georg Brandl8ec7f652007-08-15 14:28:01 +00001:mod:`getpass` --- Portable password input
2==========================================
3
4.. module:: getpass
5 :synopsis: Portable reading of passwords and retrieval of the userid.
6.. moduleauthor:: Piers Lauder <piers@cs.su.oz.au>
7.. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
Georg Brandlb19be572007-12-29 10:57:00 +00008.. Windows (& Mac?) support by Guido van Rossum.
Georg Brandl8ec7f652007-08-15 14:28:01 +00009
10The :mod:`getpass` module provides two functions:
11
12
13.. function:: getpass([prompt[, stream]])
14
15 Prompt the user for a password without echoing. The user is prompted using the
16 string *prompt*, which defaults to ``'Password: '``. On Unix, the prompt is
17 written to the file-like object *stream*, which defaults to ``sys.stdout`` (this
18 argument is ignored on Windows).
19
20 Availability: Macintosh, Unix, Windows.
21
22 .. versionchanged:: 2.5
23 The *stream* parameter was added.
24
25
26.. function:: getuser()
27
28 Return the "login name" of the user. Availability: Unix, Windows.
29
30 This function checks the environment variables :envvar:`LOGNAME`,
31 :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and returns
32 the value of the first one which is set to a non-empty string. If none are set,
33 the login name from the password database is returned on systems which support
34 the :mod:`pwd` module, otherwise, an exception is raised.
35