CHips L MINI SHELL

CHips L pro

Current Path : /proc/2/root/usr/share/doc/python-docs-2.6.6/html/library/
Upload File :
Current File : //proc/2/root/usr/share/doc/python-docs-2.6.6/html/library/user.html

<!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>27.14. user — User-specific configuration hook &mdash; 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="27. Python Runtime Services" href="python.html" />
    <link rel="next" title="27.15. fpectl — Floating point exception control" href="fpectl.html" />
    <link rel="prev" title="27.13. site — Site-specific configuration hook" href="site.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="fpectl.html" title="27.15. fpectl — Floating point exception control"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="site.html" title="27.13. site — Site-specific configuration hook"
             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> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="python.html" accesskey="U">27. Python Runtime Services</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-user">
<h1>27.14. <tt class="xref docutils literal"><span class="pre">user</span></tt> &#8212; User-specific configuration hook<a class="headerlink" href="#module-user" title="Permalink to this headline">¶</a></h1>
<p class="deprecated">
<span class="versionmodified">Deprecated since version 2.6: </span>The <tt class="xref docutils literal"><span class="pre">user</span></tt> module has been removed in Python 3.0.</p>
<p id="index-727">As a policy, Python doesn&#8217;t run user-specified code on startup of Python
programs.  (Only interactive sessions execute the script specified in the
<span class="target" id="index-728"></span><a class="reference external" href="../using/cmdline.html#envvar-PYTHONSTARTUP"><strong class="xref">PYTHONSTARTUP</strong></a> environment variable if it exists).</p>
<p>However, some programs or sites may find it convenient to allow users to have a
standard customization file, which gets run when a program requests it.  This
module implements such a mechanism.  A program that wishes to use the mechanism
must execute the statement</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">user</span>
</pre></div>
</div>
<p id="index-729">The <tt class="xref docutils literal"><span class="pre">user</span></tt> module looks for a file <tt class="docutils literal"><span class="pre">.pythonrc.py</span></tt> in the user&#8217;s home
directory and if it can be opened, executes it (using <a title="execfile" class="reference external" href="functions.html#execfile"><tt class="xref docutils literal"><span class="pre">execfile()</span></tt></a>) in its
own (the module <tt class="xref docutils literal"><span class="pre">user</span></tt>&#8216;s) global namespace.  Errors during this phase are
not caught; that&#8217;s up to the program that imports the <tt class="xref docutils literal"><span class="pre">user</span></tt> module, if it
wishes.  The home directory is assumed to be named by the <span class="target" id="index-730"></span><strong class="xref">HOME</strong>
environment variable; if this is not set, the current directory is used.</p>
<p>The user&#8217;s <tt class="docutils literal"><span class="pre">.pythonrc.py</span></tt> could conceivably test for <tt class="docutils literal"><span class="pre">sys.version</span></tt> if it
wishes to do different things depending on the Python version.</p>
<p>A warning to users: be very conservative in what you place in your
<tt class="docutils literal"><span class="pre">.pythonrc.py</span></tt> file.  Since you don&#8217;t know which programs will use it,
changing the behavior of standard modules or functions is generally not a good
idea.</p>
<p>A suggestion for programmers who wish to use this mechanism: a simple way to let
users specify options for your package is to have them define variables in their
<tt class="docutils literal"><span class="pre">.pythonrc.py</span></tt> file that you test in your module.  For example, a module
<tt class="xref docutils literal"><span class="pre">spam</span></tt> that has a verbosity level can look for a variable
<tt class="docutils literal"><span class="pre">user.spam_verbose</span></tt>, as follows:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">user</span>

<span class="n">verbose</span> <span class="o">=</span> <span class="nb">bool</span><span class="p">(</span><span class="nb">getattr</span><span class="p">(</span><span class="n">user</span><span class="p">,</span> <span class="s">&quot;spam_verbose&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span>
</pre></div>
</div>
<p>(The three-argument form of <a title="getattr" class="reference external" href="functions.html#getattr"><tt class="xref docutils literal"><span class="pre">getattr()</span></tt></a> is used in case the user has not
defined <tt class="docutils literal"><span class="pre">spam_verbose</span></tt> in their <tt class="docutils literal"><span class="pre">.pythonrc.py</span></tt> file.)</p>
<p>Programs with extensive customization needs are better off reading a
program-specific customization file.</p>
<p>Programs with security or privacy concerns should <em>not</em> import this module; a
user can easily break into a program by placing arbitrary code in the
<tt class="docutils literal"><span class="pre">.pythonrc.py</span></tt> file.</p>
<p>Modules for general use should <em>not</em> import this module; it may interfere with
the operation of the importing program.</p>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<dl class="last docutils">
<dt>Module <a title="A standard way to reference site-specific modules." class="reference external" href="site.html#module-site"><tt class="xref docutils literal"><span class="pre">site</span></tt></a></dt>
<dd>Site-wide customization mechanism.</dd>
</dl>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h4>Previous topic</h4>
            <p class="topless"><a href="site.html"
                                  title="previous chapter">27.13. <tt class="docutils literal docutils literal docutils literal"><span class="pre">site</span></tt> &#8212; Site-specific configuration hook</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="fpectl.html"
                                  title="next chapter">27.15. <tt class="docutils literal docutils literal docutils literal"><span class="pre">fpectl</span></tt> &#8212; Floating point exception control</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/user.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="fpectl.html" title="27.15. fpectl — Floating point exception control"
             >next</a> |</li>
        <li class="right" >
          <a href="site.html" title="27.13. site — Site-specific configuration hook"
             >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> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="python.html" >27. Python Runtime Services</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
    &copy; <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