~ubuntu-branches/ubuntu/trusty/python3.4/trusty-proposed

« back to all changes in this revision

Viewing changes to Doc/library/getpass.rst

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2013-11-25 09:44:27 UTC
  • Revision ID: package-import@ubuntu.com-20131125094427-lzxj8ap5w01lmo7f
Tags: upstream-3.4~b1
ImportĀ upstreamĀ versionĀ 3.4~b1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
10
The :mod:`getpass` module provides two functions:
 
11
 
 
12
 
 
13
.. function:: getpass(prompt='Password: ', stream=None)
 
14
 
 
15
   Prompt the user for a password without echoing.  The user is prompted using
 
16
   the string *prompt*, which defaults to ``'Password: '``.  On Unix, the prompt
 
17
   is written to the file-like object *stream*.  *stream* defaults to the
 
18
   controlling terminal (:file:`/dev/tty`) or if that is unavailable to
 
19
   ``sys.stderr`` (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
   .. note::
 
28
      If you call getpass from within IDLE, the input may be done in the
 
29
      terminal you launched IDLE from rather than the idle window itself.
 
30
 
 
31
.. exception:: GetPassWarning
 
32
 
 
33
   A :exc:`UserWarning` subclass issued when password input may be echoed.
 
34
 
 
35
 
 
36
.. function:: getuser()
 
37
 
 
38
   Return the "login name" of the user. Availability: Unix, Windows.
 
39
 
 
40
   This function checks the environment variables :envvar:`LOGNAME`,
 
41
   :envvar:`USER`, :envvar:`LNAME` and :envvar:`USERNAME`, in order, and returns
 
42
   the value of the first one which is set to a non-empty string.  If none are set,
 
43
   the login name from the password database is returned on systems which support
 
44
   the :mod:`pwd` module, otherwise, an exception is raised.
 
45