Sophie

Sophie

distrib > Mandriva > 10.1 > i586 > by-pkgid > ccf83290023404568bb21aa0163b385f > files > 477

python-docs-2.3.4-6.2.101mdk.i586.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.gif" />
<link rel='start' href='../index.html' title='Python Documentation Index' />
<link rel="first" href="lib.html" title='Python Library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<LINK rel="next" href="module-curses.panel.html">
<LINK rel="prev" href="module-curses.wrapper.html">
<LINK rel="parent" href="allos.html">
<LINK rel="next" href="module-curses.panel.html">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name='aesop' content='information' />
<META name="description" content="curses.ascii -- Utilities for ASCII characters">
<META name="keywords" content="lib">
<META name="resource-type" content="document">
<META name="distribution" content="global">
<title>6.17 curses.ascii -- Utilities for ASCII characters</title>
</head>
<body>
<DIV CLASS="navigation">
<div id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.16 curses.wrapper  " 
  href="module-curses.wrapper.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="6. Generic Operating System" 
  href="allos.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="6.18 curses.panel  " 
  href="module-curses.panel.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents" 
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index" 
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-curses.wrapper.html">6.16 curses.wrapper  </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="allos.html">6. Generic Operating System</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-curses.panel.html">6.18 curses.panel  </A>
</div>
<hr /></div>
</DIV>
<!--End of Navigation Panel-->

<H1><A NAME="SECTION0081700000000000000000">
6.17 <tt class="module">curses.ascii</tt> --
         Utilities for ASCII characters</A>
</H1>

<P>
<A NAME="module-curses.ascii"><!--z--></A>

<P>

<span class="versionnote">New in version 1.6.</span>

<P>
The <tt class="module">curses.ascii</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 align="center" style="border-collapse: collapse">
  <thead>
    <tr class="tableheader">
      <th align="left"><b>Name</b>&nbsp;</th>
      <th align="left"><b>Meaning</b>&nbsp;</th>
      </tr>
    </thead>
  <tbody valign="baseline">
    <tr><td align="left" valign="baseline"><tt class="constant">NUL</tt></td>
        <td align="left">&nbsp;</td>
    <tr><td align="left" valign="baseline"><tt class="constant">SOH</tt></td>
        <td align="left">Start of heading, console interrupt</td>
    <tr><td align="left" valign="baseline"><tt class="constant">STX</tt></td>
        <td align="left">Start of text</td>
    <tr><td align="left" valign="baseline"><tt class="constant">ETX</tt></td>
        <td align="left">End of text</td>
    <tr><td align="left" valign="baseline"><tt class="constant">EOT</tt></td>
        <td align="left">End of transmission</td>
    <tr><td align="left" valign="baseline"><tt class="constant">ENQ</tt></td>
        <td align="left">Enquiry, goes with <tt class="constant">ACK</tt> flow control</td>
    <tr><td align="left" valign="baseline"><tt class="constant">ACK</tt></td>
        <td align="left">Acknowledgement</td>
    <tr><td align="left" valign="baseline"><tt class="constant">BEL</tt></td>
        <td align="left">Bell</td>
    <tr><td align="left" valign="baseline"><tt class="constant">BS</tt></td>
        <td align="left">Backspace</td>
    <tr><td align="left" valign="baseline"><tt class="constant">TAB</tt></td>
        <td align="left">Tab</td>
    <tr><td align="left" valign="baseline"><tt class="constant">HT</tt></td>
        <td align="left">Alias for <tt class="constant">TAB</tt>: ``Horizontal tab''</td>
    <tr><td align="left" valign="baseline"><tt class="constant">LF</tt></td>
        <td align="left">Line feed</td>
    <tr><td align="left" valign="baseline"><tt class="constant">NL</tt></td>
        <td align="left">Alias for <tt class="constant">LF</tt>: ``New line''</td>
    <tr><td align="left" valign="baseline"><tt class="constant">VT</tt></td>
        <td align="left">Vertical tab</td>
    <tr><td align="left" valign="baseline"><tt class="constant">FF</tt></td>
        <td align="left">Form feed</td>
    <tr><td align="left" valign="baseline"><tt class="constant">CR</tt></td>
        <td align="left">Carriage return</td>
    <tr><td align="left" valign="baseline"><tt class="constant">SO</tt></td>
        <td align="left">Shift-out, begin alternate character set</td>
    <tr><td align="left" valign="baseline"><tt class="constant">SI</tt></td>
        <td align="left">Shift-in, resume default character set</td>
    <tr><td align="left" valign="baseline"><tt class="constant">DLE</tt></td>
        <td align="left">Data-link escape</td>
    <tr><td align="left" valign="baseline"><tt class="constant">DC1</tt></td>
        <td align="left">XON, for flow control</td>
    <tr><td align="left" valign="baseline"><tt class="constant">DC2</tt></td>
        <td align="left">Device control 2, block-mode flow control</td>
    <tr><td align="left" valign="baseline"><tt class="constant">DC3</tt></td>
        <td align="left">XOFF, for flow control</td>
    <tr><td align="left" valign="baseline"><tt class="constant">DC4</tt></td>
        <td align="left">Device control 4</td>
    <tr><td align="left" valign="baseline"><tt class="constant">NAK</tt></td>
        <td align="left">Negative acknowledgement</td>
    <tr><td align="left" valign="baseline"><tt class="constant">SYN</tt></td>
        <td align="left">Synchronous idle</td>
    <tr><td align="left" valign="baseline"><tt class="constant">ETB</tt></td>
        <td align="left">End transmission block</td>
    <tr><td align="left" valign="baseline"><tt class="constant">CAN</tt></td>
        <td align="left">Cancel</td>
    <tr><td align="left" valign="baseline"><tt class="constant">EM</tt></td>
        <td align="left">End of medium</td>
    <tr><td align="left" valign="baseline"><tt class="constant">SUB</tt></td>
        <td align="left">Substitute</td>
    <tr><td align="left" valign="baseline"><tt class="constant">ESC</tt></td>
        <td align="left">Escape</td>
    <tr><td align="left" valign="baseline"><tt class="constant">FS</tt></td>
        <td align="left">File separator</td>
    <tr><td align="left" valign="baseline"><tt class="constant">GS</tt></td>
        <td align="left">Group separator</td>
    <tr><td align="left" valign="baseline"><tt class="constant">RS</tt></td>
        <td align="left">Record separator, block-mode terminator</td>
    <tr><td align="left" valign="baseline"><tt class="constant">US</tt></td>
        <td align="left">Unit separator</td>
    <tr><td align="left" valign="baseline"><tt class="constant">SP</tt></td>
        <td align="left">Space</td>
    <tr><td align="left" valign="baseline"><tt class="constant">DEL</tt></td>
        <td align="left">Delete</td></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>
The module supplies the following functions, patterned on those in the
standard C library:

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1964' class="function">isalnum</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII alphanumeric character; it is equivalent to
"<tt class="samp">isalpha(<var>c</var>) or isdigit(<var>c</var>)</tt>".
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1965' class="function">isalpha</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII alphabetic character; it is equivalent to
"<tt class="samp">isupper(<var>c</var>) or islower(<var>c</var>)</tt>".
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1966' class="function">isascii</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for a character value that fits in the 7-bit ASCII set.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1967' class="function">isblank</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII whitespace character.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1968' class="function">iscntrl</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII control character (in the range 0x00 to 0x1f).
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1969' class="function">isdigit</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII decimal digit, "<tt class="character">0</tt>" through
"<tt class="character">9</tt>".  This is equivalent to "<tt class="samp"><var>c</var> in string.digits</tt>".
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1970' class="function">isgraph</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for ASCII any printable character except space.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1971' class="function">islower</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII lower-case character.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1972' class="function">isprint</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for any ASCII printable character including space.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1973' class="function">ispunct</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for any printable ASCII character which is not a space or an
alphanumeric character.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1974' class="function">isspace</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for ASCII white-space characters; space, line feed,
carriage return, form feed, horizontal tab, vertical tab.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1975' class="function">isupper</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII uppercase letter.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1976' class="function">isxdigit</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII hexadecimal digit.  This is equivalent to
"<tt class="samp"><var>c</var> in string.hexdigits</tt>".
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1977' class="function">isctrl</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for an ASCII control character (ordinal values 0 to 31).
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1978' class="function">ismeta</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Checks for a non-ASCII character (ordinal values 0x80 and above).
</dl>

<P>
These functions accept either integers or strings; when the argument
is a string, it is first converted using the built-in function
<tt class="function">ord()</tt>.

<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 <tt class="module"><a href="module-string.html">string</a></tt> module.

<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><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1979' class="function">ascii</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Return the ASCII value corresponding to the low 7 bits of <var>c</var>.
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1980' class="function">ctrl</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Return the control character corresponding to the given character
(the character bit value is bitwise-anded with 0x1f).
</dl>

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1981' class="function">alt</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Return the 8-bit character corresponding to the given ASCII character
(the character bit value is bitwise-ored with 0x80).
</dl>

<P>
The following function takes either a single-character string or
integer value; it returns a string.

<P>
<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
  <td><nobr><b><tt id='l2h-1982' class="function">unctrl</tt></b>(</nobr></td>
  <td><var>c</var>)</td></tr></table></dt>
<dd>
Return a string representation of the ASCII character <var>c</var>.  If
<var>c</var> 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="character">^</tt>") followed by the corresponding uppercase letter.
If the character is an ASCII delete (0x7f) the string is
<code>'^?'</code>.  If the character has its meta bit (0x80) set, the meta
bit is stripped, the preceding rules applied, and
"<tt class="character">!</tt>" prepended to the result.
</dl>

<P>
<dl><dt><b><tt id='l2h-1983'>controlnames</tt></b></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="samp">SP</tt>" for the space character.
</dd></dl>

<DIV CLASS="navigation">
<div class='online-navigation'><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="6.16 curses.wrapper  " 
  rel="prev" title="6.16 curses.wrapper  " 
  href="module-curses.wrapper.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></A></td>
<td class='online-navigation'><a rel="parent" title="6. Generic Operating System" 
  rel="parent" title="6. Generic Operating System" 
  href="allos.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up One Level' width='32' /></A></td>
<td class='online-navigation'><a rel="next" title="6.18 curses.panel  " 
  rel="next" title="6.18 curses.panel  " 
  href="module-curses.panel.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></A></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents" 
  rel="contents" title="Table of Contents" 
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></A></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index" 
  rel="index" title="Index" 
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></A></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="module-curses.wrapper.html">6.16 curses.wrapper  </A>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="allos.html">6. Generic Operating System</A>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="module-curses.panel.html">6.18 curses.panel  </A>
</div>
</div>
<hr />
<span class="release-info">Release 2.3.4, documentation updated on May 20, 2004.</span>
</DIV>
<!--End of Navigation Panel-->
<ADDRESS>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</ADDRESS>
</BODY>
</HTML>