<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>15.7. getpass — Portable password input — Python v2.6.6 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '2.6.6',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="search" type="application/opensearchdescription+xml"
title="Search within Python v2.6.6 documentation"
href="../_static/opensearch.xml"/>
<link rel="author" title="About these documents" href="../about.html" />
<link rel="copyright" title="Copyright" href="../copyright.html" />
<link rel="top" title="Python v2.6.6 documentation" href="../index.html" />
<link rel="up" title="15. Generic Operating System Services" href="allos.html" />
<link rel="next" title="15.8. curses — Terminal handling for character-cell displays" href="curses.html" />
<link rel="prev" title="15.6. logging — Logging facility for Python" href="logging.html" />
<link rel="shortcut icon" type="image/png" href="../_static/py.png" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
accesskey="M">modules</a> |</li>
<li class="right" >
<a href="curses.html" title="15.8. curses — Terminal handling for character-cell displays"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="logging.html" title="15.6. logging — Logging facility for Python"
accesskey="P">previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="allos.html" accesskey="U">15. Generic Operating System Services</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="module-getpass">
<h1>15.7. <tt class="xref docutils literal"><span class="pre">getpass</span></tt> — Portable password input<a class="headerlink" href="#module-getpass" title="Permalink to this headline">¶</a></h1>
<p>The <tt class="xref docutils literal"><span class="pre">getpass</span></tt> module provides two functions:</p>
<dl class="function">
<dt id="getpass.getpass">
<tt class="descclassname">getpass.</tt><tt class="descname">getpass</tt><big>(</big><span class="optional">[</span><em>prompt</em><span class="optional">[</span>, <em>stream</em><span class="optional">]</span><span class="optional">]</span><big>)</big><a class="headerlink" href="#getpass.getpass" title="Permalink to this definition">¶</a></dt>
<dd><p>Prompt the user for a password without echoing. The user is prompted using the
string <em>prompt</em>, which defaults to <tt class="docutils literal"><span class="pre">'Password:</span> <span class="pre">'</span></tt>. On Unix, the prompt is
written to the file-like object <em>stream</em>. <em>stream</em> defaults to the
controlling terminal (/dev/tty) or if that is unavailable to <tt class="docutils literal"><span class="pre">sys.stderr</span></tt>
(this argument is ignored on Windows).</p>
<p>If echo free input is unavailable getpass() falls back to printing
a warning message to <em>stream</em> and reading from <tt class="docutils literal"><span class="pre">sys.stdin</span></tt> and
issuing a <a title="getpass.GetPassWarning" class="reference internal" href="#getpass.GetPassWarning"><tt class="xref docutils literal"><span class="pre">GetPassWarning</span></tt></a>.</p>
<p>Availability: Macintosh, Unix, Windows.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>The <em>stream</em> parameter was added.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.6: </span>On Unix it defaults to using /dev/tty before falling back
to <tt class="docutils literal"><span class="pre">sys.stdin</span></tt> and <tt class="docutils literal"><span class="pre">sys.stderr</span></tt>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">If you call getpass from within IDLE, the input may be done in the
terminal you launched IDLE from rather than the idle window itself.</p>
</div>
</dd></dl>
<dl class="exception">
<dt id="getpass.GetPassWarning">
<em class="property">exception </em><tt class="descclassname">getpass.</tt><tt class="descname">GetPassWarning</tt><a class="headerlink" href="#getpass.GetPassWarning" title="Permalink to this definition">¶</a></dt>
<dd>A <a title="exceptions.UserWarning" class="reference external" href="exceptions.html#exceptions.UserWarning"><tt class="xref docutils literal"><span class="pre">UserWarning</span></tt></a> subclass issued when password input may be echoed.</dd></dl>
<dl class="function">
<dt id="getpass.getuser">
<tt class="descclassname">getpass.</tt><tt class="descname">getuser</tt><big>(</big><big>)</big><a class="headerlink" href="#getpass.getuser" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the “login name” of the user. Availability: Unix, Windows.</p>
<p>This function checks the environment variables <span class="target" id="index-355"></span><strong class="xref">LOGNAME</strong>,
<span class="target" id="index-356"></span><strong class="xref">USER</strong>, <span class="target" id="index-357"></span><strong class="xref">LNAME</strong> and <span class="target" id="index-358"></span><strong class="xref">USERNAME</strong>, in order, and returns
the value of the first one which is set to a non-empty string. If none are set,
the login name from the password database is returned on systems which support
the <a title="(Unix) The password database (getpwnam() and friends)." class="reference external" href="pwd.html#module-pwd"><tt class="xref docutils literal"><span class="pre">pwd</span></tt></a> module, otherwise, an exception is raised.</p>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="logging.html"
title="previous chapter">15.6. <tt class="docutils literal docutils literal"><span class="pre">logging</span></tt> — Logging facility for Python</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="curses.html"
title="next chapter">15.8. <tt class="docutils literal docutils literal docutils literal"><span class="pre">curses</span></tt> — Terminal handling for character-cell displays</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../bugs.html">Report a Bug</a></li>
<li><a href="../_sources/library/getpass.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../modindex.html" title="Global Module Index"
>modules</a> |</li>
<li class="right" >
<a href="curses.html" title="15.8. curses — Terminal handling for character-cell displays"
>next</a> |</li>
<li class="right" >
<a href="logging.html" title="15.6. logging — Logging facility for Python"
>previous</a> |</li>
<li><img src="../_static/py.png" alt=""
style="vertical-align: middle; margin-top: -1px"/></li>
<li><a href="../index.html">Python v2.6.6 documentation</a> »</li>
<li><a href="index.html" >The Python Standard Library</a> »</li>
<li><a href="allos.html" >15. Generic Operating System Services</a> »</li>
</ul>
</div>
<div class="footer">
© <a href="../copyright.html">Copyright</a> 1990-2011, Python Software Foundation.
<br />
The Python Software Foundation is a non-profit corporation.
<a href="http://www.python.org/psf/donations/">Please donate.</a>
<br />
Last updated on Jul 20, 2011.
<a href="../bugs.html">Found a bug</a>?
<br />
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.6.
</div>
</body>
</html>
Copyright 2K16 - 2K18 Indonesian Hacker Rulez