PageRenderTime 30ms CodeModel.GetById 22ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/Doc/library/getpass.rst

http://unladen-swallow.googlecode.com/
ReStructuredText | 51 lines | 35 code | 16 blank | 0 comment | 0 complexity | cf39c67a30fc3cf0565ca244240f2c9e MD5 | raw file
 1: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>
 8.. Windows (& Mac?) support by Guido van Rossum.
 9
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*.  *stream* defaults to the
18   controlling terminal (/dev/tty) or if that is unavailable to ``sys.stderr``
19   (this argument is ignored on Windows).
20
21   If echo free input is unavailable getpass() falls back to printing
22   a warning message to *stream* and reading from ``sys.stdin`` and
23   issuing a :exc:`GetPassWarning`.
24
25   Availability: Macintosh, Unix, Windows.
26
27   .. versionchanged:: 2.5
28      The *stream* parameter was added.
29   .. versionchanged:: 2.6
30      On Unix it defaults to using /dev/tty before falling back
31      to ``sys.stdin`` and ``sys.stderr``.
32   .. note::
33      If you call getpass from within IDLE, the input may be done in the
34      terminal you launched IDLE from rather than the idle window itself.
35
36
37.. exception:: GetPassWarning
38
39   A :exc:`UserWarning` subclass issued when password input may be echoed.
40
41
42.. function:: getuser()
43
44   Return the "login name" of the user. Availability: Unix, Windows.
45
46   This function checks the environment variables :envvar:`LOGNAME`,
47   :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and returns
48   the value of the first one which is set to a non-empty string.  If none are set,
49   the login name from the password database is returned on systems which support
50   the :mod:`pwd` module, otherwise, an exception is raised.
51