Sophie

Sophie

distrib > Mageia > 1 > i586 > by-pkgid > 91bb3c9e1324baf3de1e1ab7cfe48dc0 > files > 834

python-docs-2.7.1-6.1.mga1.i586.rpm

<!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>34.2. msvcrt – Useful routines from the MS VC++ runtime &mdash; Python v2.7.1 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.7.1',
        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.7.1 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.7.1 documentation" href="../index.html" />
    <link rel="up" title="34. MS Windows Specific Services" href="windows.html" />
    <link rel="next" title="34.3. _winreg – Windows registry access" href="_winreg.html" />
    <link rel="prev" title="34.1. msilib — Read and write Microsoft Installer files" href="msilib.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="_winreg.html" title="34.3. _winreg – Windows registry access"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="msilib.html" title="34.1. msilib — Read and write Microsoft Installer files"
             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.7.1 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="windows.html" accesskey="U">34. MS Windows Specific Services</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-msvcrt">
<h1>34.2. <tt class="xref docutils literal"><span class="pre">msvcrt</span></tt> &#8211; Useful routines from the MS VC++ runtime<a class="headerlink" href="#module-msvcrt" title="Permalink to this headline">¶</a></h1>
<p><em>Platforms: </em>Windows</p>
<p>These functions provide access to some useful capabilities on Windows platforms.
Some higher-level modules use these functions to build the  Windows
implementations of their services.  For example, the <a title="Portable reading of passwords and retrieval of the userid." class="reference external" href="getpass.html#module-getpass"><tt class="xref docutils literal"><span class="pre">getpass</span></tt></a> module uses
this in the implementation of the <tt class="xref docutils literal"><span class="pre">getpass()</span></tt> function.</p>
<p>Further documentation on these functions can be found in the Platform API
documentation.</p>
<p>The module implements both the normal and wide char variants of the console I/O
api. The normal API deals only with ASCII characters and is of limited use
for internationalized applications. The wide char API should be used where
ever possible</p>
<div class="section" id="file-operations">
<span id="msvcrt-files"></span><h2>34.2.1. File Operations<a class="headerlink" href="#file-operations" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="msvcrt.locking">
<tt class="descclassname">msvcrt.</tt><tt class="descname">locking</tt><big>(</big><em>fd</em>, <em>mode</em>, <em>nbytes</em><big>)</big><a class="headerlink" href="#msvcrt.locking" title="Permalink to this definition">¶</a></dt>
<dd>Lock part of a file based on file descriptor <em>fd</em> from the C runtime.  Raises
<a title="exceptions.IOError" class="reference external" href="exceptions.html#exceptions.IOError"><tt class="xref docutils literal"><span class="pre">IOError</span></tt></a> on failure.  The locked region of the file extends from the
current file position for <em>nbytes</em> bytes, and may continue beyond the end of the
file.  <em>mode</em> must be one of the <tt class="xref docutils literal"><span class="pre">LK_*</span></tt> constants listed below. Multiple
regions in a file may be locked at the same time, but may not overlap.  Adjacent
regions are not merged; they must be unlocked individually.</dd></dl>

<dl class="data">
<dt id="msvcrt.LK_LOCK">
<tt class="descclassname">msvcrt.</tt><tt class="descname">LK_LOCK</tt><a class="headerlink" href="#msvcrt.LK_LOCK" title="Permalink to this definition">¶</a></dt>
<dt id="msvcrt.LK_RLCK">
<tt class="descclassname">msvcrt.</tt><tt class="descname">LK_RLCK</tt><a class="headerlink" href="#msvcrt.LK_RLCK" title="Permalink to this definition">¶</a></dt>
<dd>Locks the specified bytes. If the bytes cannot be locked, the program
immediately tries again after 1 second.  If, after 10 attempts, the bytes cannot
be locked, <a title="exceptions.IOError" class="reference external" href="exceptions.html#exceptions.IOError"><tt class="xref docutils literal"><span class="pre">IOError</span></tt></a> is raised.</dd></dl>

<dl class="data">
<dt id="msvcrt.LK_NBLCK">
<tt class="descclassname">msvcrt.</tt><tt class="descname">LK_NBLCK</tt><a class="headerlink" href="#msvcrt.LK_NBLCK" title="Permalink to this definition">¶</a></dt>
<dt id="msvcrt.LK_NBRLCK">
<tt class="descclassname">msvcrt.</tt><tt class="descname">LK_NBRLCK</tt><a class="headerlink" href="#msvcrt.LK_NBRLCK" title="Permalink to this definition">¶</a></dt>
<dd>Locks the specified bytes. If the bytes cannot be locked, <a title="exceptions.IOError" class="reference external" href="exceptions.html#exceptions.IOError"><tt class="xref docutils literal"><span class="pre">IOError</span></tt></a> is
raised.</dd></dl>

<dl class="data">
<dt id="msvcrt.LK_UNLCK">
<tt class="descclassname">msvcrt.</tt><tt class="descname">LK_UNLCK</tt><a class="headerlink" href="#msvcrt.LK_UNLCK" title="Permalink to this definition">¶</a></dt>
<dd>Unlocks the specified bytes, which must have been previously locked.</dd></dl>

<dl class="function">
<dt id="msvcrt.setmode">
<tt class="descclassname">msvcrt.</tt><tt class="descname">setmode</tt><big>(</big><em>fd</em>, <em>flags</em><big>)</big><a class="headerlink" href="#msvcrt.setmode" title="Permalink to this definition">¶</a></dt>
<dd>Set the line-end translation mode for the file descriptor <em>fd</em>. To set it to
text mode, <em>flags</em> should be <a title="os.O_TEXT" class="reference external" href="os.html#os.O_TEXT"><tt class="xref docutils literal"><span class="pre">os.O_TEXT</span></tt></a>; for binary, it should be
<a title="os.O_BINARY" class="reference external" href="os.html#os.O_BINARY"><tt class="xref docutils literal"><span class="pre">os.O_BINARY</span></tt></a>.</dd></dl>

<dl class="function">
<dt id="msvcrt.open_osfhandle">
<tt class="descclassname">msvcrt.</tt><tt class="descname">open_osfhandle</tt><big>(</big><em>handle</em>, <em>flags</em><big>)</big><a class="headerlink" href="#msvcrt.open_osfhandle" title="Permalink to this definition">¶</a></dt>
<dd>Create a C runtime file descriptor from the file handle <em>handle</em>.  The <em>flags</em>
parameter should be a bitwise OR of <a title="os.O_APPEND" class="reference external" href="os.html#os.O_APPEND"><tt class="xref docutils literal"><span class="pre">os.O_APPEND</span></tt></a>, <a title="os.O_RDONLY" class="reference external" href="os.html#os.O_RDONLY"><tt class="xref docutils literal"><span class="pre">os.O_RDONLY</span></tt></a>,
and <a title="os.O_TEXT" class="reference external" href="os.html#os.O_TEXT"><tt class="xref docutils literal"><span class="pre">os.O_TEXT</span></tt></a>.  The returned file descriptor may be used as a parameter
to <a title="os.fdopen" class="reference external" href="os.html#os.fdopen"><tt class="xref docutils literal"><span class="pre">os.fdopen()</span></tt></a> to create a file object.</dd></dl>

<dl class="function">
<dt id="msvcrt.get_osfhandle">
<tt class="descclassname">msvcrt.</tt><tt class="descname">get_osfhandle</tt><big>(</big><em>fd</em><big>)</big><a class="headerlink" href="#msvcrt.get_osfhandle" title="Permalink to this definition">¶</a></dt>
<dd>Return the file handle for the file descriptor <em>fd</em>.  Raises <a title="exceptions.IOError" class="reference external" href="exceptions.html#exceptions.IOError"><tt class="xref docutils literal"><span class="pre">IOError</span></tt></a> if
<em>fd</em> is not recognized.</dd></dl>

</div>
<div class="section" id="console-i-o">
<span id="msvcrt-console"></span><h2>34.2.2. Console I/O<a class="headerlink" href="#console-i-o" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="msvcrt.kbhit">
<tt class="descclassname">msvcrt.</tt><tt class="descname">kbhit</tt><big>(</big><big>)</big><a class="headerlink" href="#msvcrt.kbhit" title="Permalink to this definition">¶</a></dt>
<dd>Return true if a keypress is waiting to be read.</dd></dl>

<dl class="function">
<dt id="msvcrt.getch">
<tt class="descclassname">msvcrt.</tt><tt class="descname">getch</tt><big>(</big><big>)</big><a class="headerlink" href="#msvcrt.getch" title="Permalink to this definition">¶</a></dt>
<dd>Read a keypress and return the resulting character.  Nothing is echoed to the
console.  This call will block if a keypress is not already available, but will
not wait for <tt class="docutils literal"><span class="pre">Enter</span></tt> to be pressed. If the pressed key was a special
function key, this will return <tt class="docutils literal"><span class="pre">'\000'</span></tt> or <tt class="docutils literal"><span class="pre">'\xe0'</span></tt>; the next call will
return the keycode.  The <tt class="docutils literal"><span class="pre">Control-C</span></tt> keypress cannot be read with this
function.</dd></dl>

<dl class="function">
<dt id="msvcrt.getwch">
<tt class="descclassname">msvcrt.</tt><tt class="descname">getwch</tt><big>(</big><big>)</big><a class="headerlink" href="#msvcrt.getwch" title="Permalink to this definition">¶</a></dt>
<dd><p>Wide char variant of <a title="msvcrt.getch" class="reference internal" href="#msvcrt.getch"><tt class="xref docutils literal"><span class="pre">getch()</span></tt></a>, returning a Unicode value.</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.6.</span></p>
</dd></dl>

<dl class="function">
<dt id="msvcrt.getche">
<tt class="descclassname">msvcrt.</tt><tt class="descname">getche</tt><big>(</big><big>)</big><a class="headerlink" href="#msvcrt.getche" title="Permalink to this definition">¶</a></dt>
<dd>Similar to <a title="msvcrt.getch" class="reference internal" href="#msvcrt.getch"><tt class="xref docutils literal"><span class="pre">getch()</span></tt></a>, but the keypress will be echoed if it  represents a
printable character.</dd></dl>

<dl class="function">
<dt id="msvcrt.getwche">
<tt class="descclassname">msvcrt.</tt><tt class="descname">getwche</tt><big>(</big><big>)</big><a class="headerlink" href="#msvcrt.getwche" title="Permalink to this definition">¶</a></dt>
<dd><p>Wide char variant of <a title="msvcrt.getche" class="reference internal" href="#msvcrt.getche"><tt class="xref docutils literal"><span class="pre">getche()</span></tt></a>, returning a Unicode value.</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.6.</span></p>
</dd></dl>

<dl class="function">
<dt id="msvcrt.putch">
<tt class="descclassname">msvcrt.</tt><tt class="descname">putch</tt><big>(</big><em>char</em><big>)</big><a class="headerlink" href="#msvcrt.putch" title="Permalink to this definition">¶</a></dt>
<dd>Print the character <em>char</em> to the console without buffering.</dd></dl>

<dl class="function">
<dt id="msvcrt.putwch">
<tt class="descclassname">msvcrt.</tt><tt class="descname">putwch</tt><big>(</big><em>unicode_char</em><big>)</big><a class="headerlink" href="#msvcrt.putwch" title="Permalink to this definition">¶</a></dt>
<dd><p>Wide char variant of <a title="msvcrt.putch" class="reference internal" href="#msvcrt.putch"><tt class="xref docutils literal"><span class="pre">putch()</span></tt></a>, accepting a Unicode value.</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.6.</span></p>
</dd></dl>

<dl class="function">
<dt id="msvcrt.ungetch">
<tt class="descclassname">msvcrt.</tt><tt class="descname">ungetch</tt><big>(</big><em>char</em><big>)</big><a class="headerlink" href="#msvcrt.ungetch" title="Permalink to this definition">¶</a></dt>
<dd>Cause the character <em>char</em> to be &#8220;pushed back&#8221; into the console buffer; it will
be the next character read by <a title="msvcrt.getch" class="reference internal" href="#msvcrt.getch"><tt class="xref docutils literal"><span class="pre">getch()</span></tt></a> or <a title="msvcrt.getche" class="reference internal" href="#msvcrt.getche"><tt class="xref docutils literal"><span class="pre">getche()</span></tt></a>.</dd></dl>

<dl class="function">
<dt id="msvcrt.ungetwch">
<tt class="descclassname">msvcrt.</tt><tt class="descname">ungetwch</tt><big>(</big><em>unicode_char</em><big>)</big><a class="headerlink" href="#msvcrt.ungetwch" title="Permalink to this definition">¶</a></dt>
<dd><p>Wide char variant of <a title="msvcrt.ungetch" class="reference internal" href="#msvcrt.ungetch"><tt class="xref docutils literal"><span class="pre">ungetch()</span></tt></a>, accepting a Unicode value.</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.6.</span></p>
</dd></dl>

</div>
<div class="section" id="other-functions">
<span id="msvcrt-other"></span><h2>34.2.3. Other Functions<a class="headerlink" href="#other-functions" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="msvcrt.heapmin">
<tt class="descclassname">msvcrt.</tt><tt class="descname">heapmin</tt><big>(</big><big>)</big><a class="headerlink" href="#msvcrt.heapmin" title="Permalink to this definition">¶</a></dt>
<dd>Force the <tt class="xref docutils literal"><span class="pre">malloc()</span></tt> heap to clean itself up and return unused blocks to
the operating system.  On failure, this raises <a title="exceptions.IOError" class="reference external" href="exceptions.html#exceptions.IOError"><tt class="xref docutils literal"><span class="pre">IOError</span></tt></a>.</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3><a href="../contents.html">Table Of Contents</a></h3>
            <ul>
<li><a class="reference external" href="#">34.2. <tt class="docutils literal"><span class="pre">msvcrt</span></tt> &#8211; Useful routines from the MS VC++ runtime</a><ul>
<li><a class="reference external" href="#file-operations">34.2.1. File Operations</a></li>
<li><a class="reference external" href="#console-i-o">34.2.2. Console I/O</a></li>
<li><a class="reference external" href="#other-functions">34.2.3. Other Functions</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="msilib.html"
                                  title="previous chapter">34.1. <tt class="docutils literal docutils literal"><span class="pre">msilib</span></tt> &#8212; Read and write Microsoft Installer files</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="_winreg.html"
                                  title="next chapter">34.3. <tt class="docutils literal docutils literal"><span class="pre">_winreg</span></tt> &#8211; Windows registry access</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/msvcrt.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="_winreg.html" title="34.3. _winreg – Windows registry access"
             >next</a> |</li>
        <li class="right" >
          <a href="msilib.html" title="34.1. msilib — Read and write Microsoft Installer files"
             >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.7.1 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Standard Library</a> &raquo;</li>
          <li><a href="windows.html" >34. MS Windows Specific Services</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 1990-2010, 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 Nov 27, 2010.
    <a href="../bugs.html">Found a bug</a>?
    <br />
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.7.
    </div>

  </body>
</html>