blob: bd384b44fa1f18f2a4f296a69ed9ab2f4c8ddeb9 [file] [log] [blame]
Georg Brandl116aa622007-08-15 14:28:22 +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>
Christian Heimes5b5e81c2007-12-31 16:14:33 +00008.. Windows (& Mac?) support by Guido van Rossum.
Georg Brandl116aa622007-08-15 14:28:22 +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
Georg Brandl116aa622007-08-15 14:28:22 +000022
23.. function:: getuser()
24
25 Return the "login name" of the user. Availability: Unix, Windows.
26
27 This function checks the environment variables :envvar:`LOGNAME`,
28 :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and returns
29 the value of the first one which is set to a non-empty string. If none are set,
30 the login name from the password database is returned on systems which support
31 the :mod:`pwd` module, otherwise, an exception is raised.
32