<!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.11. curses.ascii — Utilities for ASCII characters — 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.12. curses.panel — A panel stack extension for curses" href="curses.panel.html" />
<link rel="prev" title="15.8. curses — Terminal handling for character-cell displays" href="curses.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.panel.html" title="15.12. curses.panel — A panel stack extension for curses"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="curses.html" title="15.8. curses — Terminal handling for character-cell displays"
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-curses.ascii">
<h1>15.11. <tt class="xref docutils literal"><span class="pre">curses.ascii</span></tt> — Utilities for ASCII characters<a class="headerlink" href="#module-curses.ascii" title="Permalink to this headline">¶</a></h1>
<p class="versionadded">
<span class="versionmodified">New in version 1.6.</span></p>
<p>The <tt class="xref docutils literal"><span class="pre">curses.ascii</span></tt> module supplies name constants for ASCII characters and
functions to test membership in various ASCII character classes. The constants
supplied are names for control characters as follows:</p>
<table border="1" class="docutils">
<colgroup>
<col width="23%" />
<col width="77%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Name</th>
<th class="head">Meaning</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="xref docutils literal"><span class="pre">NUL</span></tt></td>
<td> </td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">SOH</span></tt></td>
<td>Start of heading, console interrupt</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">STX</span></tt></td>
<td>Start of text</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">ETX</span></tt></td>
<td>End of text</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">EOT</span></tt></td>
<td>End of transmission</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">ENQ</span></tt></td>
<td>Enquiry, goes with <tt class="xref docutils literal"><span class="pre">ACK</span></tt> flow control</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">ACK</span></tt></td>
<td>Acknowledgement</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">BEL</span></tt></td>
<td>Bell</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">BS</span></tt></td>
<td>Backspace</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">TAB</span></tt></td>
<td>Tab</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">HT</span></tt></td>
<td>Alias for <tt class="xref docutils literal"><span class="pre">TAB</span></tt>: “Horizontal tab”</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">LF</span></tt></td>
<td>Line feed</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">NL</span></tt></td>
<td>Alias for <tt class="xref docutils literal"><span class="pre">LF</span></tt>: “New line”</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">VT</span></tt></td>
<td>Vertical tab</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">FF</span></tt></td>
<td>Form feed</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">CR</span></tt></td>
<td>Carriage return</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">SO</span></tt></td>
<td>Shift-out, begin alternate character set</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">SI</span></tt></td>
<td>Shift-in, resume default character set</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">DLE</span></tt></td>
<td>Data-link escape</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">DC1</span></tt></td>
<td>XON, for flow control</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">DC2</span></tt></td>
<td>Device control 2, block-mode flow control</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">DC3</span></tt></td>
<td>XOFF, for flow control</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">DC4</span></tt></td>
<td>Device control 4</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">NAK</span></tt></td>
<td>Negative acknowledgement</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">SYN</span></tt></td>
<td>Synchronous idle</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">ETB</span></tt></td>
<td>End transmission block</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">CAN</span></tt></td>
<td>Cancel</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">EM</span></tt></td>
<td>End of medium</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">SUB</span></tt></td>
<td>Substitute</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">ESC</span></tt></td>
<td>Escape</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">FS</span></tt></td>
<td>File separator</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">GS</span></tt></td>
<td>Group separator</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">RS</span></tt></td>
<td>Record separator, block-mode terminator</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">US</span></tt></td>
<td>Unit separator</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">SP</span></tt></td>
<td>Space</td>
</tr>
<tr><td><tt class="xref docutils literal"><span class="pre">DEL</span></tt></td>
<td>Delete</td>
</tr>
</tbody>
</table>
<p>Note that many of these have little practical significance in modern usage. The
mnemonics derive from teleprinter conventions that predate digital computers.</p>
<p>The module supplies the following functions, patterned on those in the standard
C library:</p>
<dl class="function">
<dt id="curses.ascii.isalnum">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isalnum</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isalnum" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII alphanumeric character; it is equivalent to <tt class="docutils literal"><span class="pre">isalpha(c)</span> <span class="pre">or</span>
<span class="pre">isdigit(c)</span></tt>.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isalpha">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isalpha</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isalpha" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII alphabetic character; it is equivalent to <tt class="docutils literal"><span class="pre">isupper(c)</span> <span class="pre">or</span>
<span class="pre">islower(c)</span></tt>.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isascii">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isascii</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isascii" title="Permalink to this definition">¶</a></dt>
<dd>Checks for a character value that fits in the 7-bit ASCII set.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isblank">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isblank</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isblank" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII whitespace character.</dd></dl>
<dl class="function">
<dt id="curses.ascii.iscntrl">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">iscntrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.iscntrl" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII control character (in the range 0x00 to 0x1f).</dd></dl>
<dl class="function">
<dt id="curses.ascii.isdigit">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isdigit</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isdigit" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII decimal digit, <tt class="docutils literal"><span class="pre">'0'</span></tt> through <tt class="docutils literal"><span class="pre">'9'</span></tt>. This is equivalent
to <tt class="docutils literal"><span class="pre">c</span> <span class="pre">in</span> <span class="pre">string.digits</span></tt>.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isgraph">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isgraph</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isgraph" title="Permalink to this definition">¶</a></dt>
<dd>Checks for ASCII any printable character except space.</dd></dl>
<dl class="function">
<dt id="curses.ascii.islower">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">islower</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.islower" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII lower-case character.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isprint">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isprint</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isprint" title="Permalink to this definition">¶</a></dt>
<dd>Checks for any ASCII printable character including space.</dd></dl>
<dl class="function">
<dt id="curses.ascii.ispunct">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">ispunct</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ispunct" title="Permalink to this definition">¶</a></dt>
<dd>Checks for any printable ASCII character which is not a space or an alphanumeric
character.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isspace">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isspace</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isspace" title="Permalink to this definition">¶</a></dt>
<dd>Checks for ASCII white-space characters; space, line feed, carriage return, form
feed, horizontal tab, vertical tab.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isupper">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isupper</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isupper" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII uppercase letter.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isxdigit">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isxdigit</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isxdigit" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII hexadecimal digit. This is equivalent to <tt class="docutils literal"><span class="pre">c</span> <span class="pre">in</span>
<span class="pre">string.hexdigits</span></tt>.</dd></dl>
<dl class="function">
<dt id="curses.ascii.isctrl">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">isctrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.isctrl" title="Permalink to this definition">¶</a></dt>
<dd>Checks for an ASCII control character (ordinal values 0 to 31).</dd></dl>
<dl class="function">
<dt id="curses.ascii.ismeta">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">ismeta</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ismeta" title="Permalink to this definition">¶</a></dt>
<dd>Checks for a non-ASCII character (ordinal values 0x80 and above).</dd></dl>
<p>These functions accept either integers or strings; when the argument is a
string, it is first converted using the built-in function <a title="ord" class="reference external" href="functions.html#ord"><tt class="xref docutils literal"><span class="pre">ord()</span></tt></a>.</p>
<p>Note that all these functions check ordinal bit values derived from the first
character of the string you pass in; they do not actually know anything about
the host machine’s character encoding. For functions that know about the
character encoding (and handle internationalization properly) see the
<a title="Common string operations." class="reference external" href="string.html#module-string"><tt class="xref docutils literal"><span class="pre">string</span></tt></a> module.</p>
<p>The following two functions take either a single-character string or integer
byte value; they return a value of the same type.</p>
<dl class="function">
<dt id="curses.ascii.ascii">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">ascii</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ascii" title="Permalink to this definition">¶</a></dt>
<dd>Return the ASCII value corresponding to the low 7 bits of <em>c</em>.</dd></dl>
<dl class="function">
<dt id="curses.ascii.ctrl">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">ctrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.ctrl" title="Permalink to this definition">¶</a></dt>
<dd>Return the control character corresponding to the given character (the character
bit value is bitwise-anded with 0x1f).</dd></dl>
<dl class="function">
<dt id="curses.ascii.alt">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">alt</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.alt" title="Permalink to this definition">¶</a></dt>
<dd>Return the 8-bit character corresponding to the given ASCII character (the
character bit value is bitwise-ored with 0x80).</dd></dl>
<p>The following function takes either a single-character string or integer value;
it returns a string.</p>
<dl class="function">
<dt id="curses.ascii.unctrl">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">unctrl</tt><big>(</big><em>c</em><big>)</big><a class="headerlink" href="#curses.ascii.unctrl" title="Permalink to this definition">¶</a></dt>
<dd>Return a string representation of the ASCII character <em>c</em>. If <em>c</em> is printable,
this string is the character itself. If the character is a control character
(0x00-0x1f) the string consists of a caret (<tt class="docutils literal"><span class="pre">'^'</span></tt>) followed by the
corresponding uppercase letter. If the character is an ASCII delete (0x7f) the
string is <tt class="docutils literal"><span class="pre">'^?'</span></tt>. If the character has its meta bit (0x80) set, the meta bit
is stripped, the preceding rules applied, and <tt class="docutils literal"><span class="pre">'!'</span></tt> prepended to the result.</dd></dl>
<dl class="data">
<dt id="curses.ascii.controlnames">
<tt class="descclassname">curses.ascii.</tt><tt class="descname">controlnames</tt><a class="headerlink" href="#curses.ascii.controlnames" title="Permalink to this definition">¶</a></dt>
<dd>A 33-element string array that contains the ASCII mnemonics for the thirty-two
ASCII control characters from 0 (NUL) to 0x1f (US), in order, plus the mnemonic
<tt class="docutils literal"><span class="pre">SP</span></tt> for the space character.</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h4>Previous topic</h4>
<p class="topless"><a href="curses.html"
title="previous chapter">15.8. <tt class="docutils literal docutils literal"><span class="pre">curses</span></tt> — Terminal handling for character-cell displays</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="curses.panel.html"
title="next chapter">15.12. <tt class="docutils literal"><span class="pre">curses.panel</span></tt> — A panel stack extension for curses</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/curses.ascii.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.panel.html" title="15.12. curses.panel — A panel stack extension for curses"
>next</a> |</li>
<li class="right" >
<a href="curses.html" title="15.8. curses — Terminal handling for character-cell displays"
>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