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