Sophie

Sophie

distrib > Mandriva > current > i586 > by-pkgid > 8f1462e52e1797a02c97073eed0b7f92 > files > 972

python-docs-2.6.5-2.5mdv2010.2.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>2. Lexical analysis &mdash; Python v2.6.5 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.5',
        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.5 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.5 documentation" href="../index.html" />
    <link rel="up" title="The Python Language Reference" href="index.html" />
    <link rel="next" title="3. Data model" href="datamodel.html" />
    <link rel="prev" title="1. Introduction" href="introduction.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="datamodel.html" title="3. Data model"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="introduction.html" title="1. Introduction"
             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.5 documentation</a> &raquo;</li>

          <li><a href="index.html" accesskey="U">The Python Language Reference</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="lexical-analysis">
<span id="lexical"></span><h1>2. Lexical analysis<a class="headerlink" href="#lexical-analysis" title="Permalink to this headline">¶</a></h1>
<p id="index-980">A Python program is read by a <em>parser</em>.  Input to the parser is a stream of
<em>tokens</em>, generated by the <em>lexical analyzer</em>.  This chapter describes how the
lexical analyzer breaks a file into tokens.</p>
<p>Python uses the 7-bit ASCII character set for program text.</p>
<p class="versionadded">
<span class="versionmodified">New in version 2.3: </span>An encoding declaration can be used to indicate that  string literals and
comments use an encoding different from ASCII.</p>
<p>For compatibility with older versions, Python only warns if it finds 8-bit
characters; those warnings should be corrected by either declaring an explicit
encoding, or using escape sequences if those bytes are binary data, instead of
characters.</p>
<p>The run-time character set depends on the I/O devices connected to the program
but is generally a superset of ASCII.</p>
<p><strong>Future compatibility note:</strong> It may be tempting to assume that the character
set for 8-bit characters is ISO Latin-1 (an ASCII superset that covers most
western languages that use the Latin alphabet), but it is possible that in the
future Unicode text editors will become common.  These generally use the UTF-8
encoding, which is also an ASCII superset, but with very different use for the
characters with ordinals 128-255.  While there is no consensus on this subject
yet, it is unwise to assume either Latin-1 or UTF-8, even though the current
implementation appears to favor Latin-1.  This applies both to the source
character set and the run-time character set.</p>
<div class="section" id="line-structure">
<span id="id1"></span><h2>2.1. Line structure<a class="headerlink" href="#line-structure" title="Permalink to this headline">¶</a></h2>
<p id="index-981">A Python program is divided into a number of <em>logical lines</em>.</p>
<div class="section" id="logical-lines">
<span id="logical"></span><h3>2.1.1. Logical lines<a class="headerlink" href="#logical-lines" title="Permalink to this headline">¶</a></h3>
<p id="index-982">The end of a logical line is represented by the token NEWLINE.  Statements
cannot cross logical line boundaries except where NEWLINE is allowed by the
syntax (e.g., between statements in compound statements). A logical line is
constructed from one or more <em>physical lines</em> by following the explicit or
implicit <em>line joining</em> rules.</p>
</div>
<div class="section" id="physical-lines">
<span id="physical"></span><h3>2.1.2. Physical lines<a class="headerlink" href="#physical-lines" title="Permalink to this headline">¶</a></h3>
<p>A physical line is a sequence of characters terminated by an end-of-line
sequence.  In source files, any of the standard platform line termination
sequences can be used - the Unix form using ASCII LF (linefeed), the Windows
form using the ASCII sequence CR LF (return followed by linefeed), or the old
Macintosh form using the ASCII CR (return) character.  All of these forms can be
used equally, regardless of platform.</p>
<p>When embedding Python, source code strings should be passed to Python APIs using
the standard C conventions for newline characters (the <tt class="docutils literal"><span class="pre">\n</span></tt> character,
representing ASCII LF, is the line terminator).</p>
</div>
<div class="section" id="comments">
<span id="id2"></span><h3>2.1.3. Comments<a class="headerlink" href="#comments" title="Permalink to this headline">¶</a></h3>
<p id="index-983">A comment starts with a hash character (<tt class="docutils literal"><span class="pre">#</span></tt>) that is not part of a string
literal, and ends at the end of the physical line.  A comment signifies the end
of the logical line unless the implicit line joining rules are invoked. Comments
are ignored by the syntax; they are not tokens.</p>
</div>
<div class="section" id="encoding-declarations">
<span id="encodings"></span><h3>2.1.4. Encoding declarations<a class="headerlink" href="#encoding-declarations" title="Permalink to this headline">¶</a></h3>
<p id="index-984">If a comment in the first or second line of the Python script matches the
regular expression <tt class="docutils literal"><span class="pre">coding[=:]\s*([-\w.]+)</span></tt>, this comment is processed as an
encoding declaration; the first group of this expression names the encoding of
the source code file. The recommended forms of this expression are</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># -*- coding: &lt;encoding-name&gt; -*-</span>
</pre></div>
</div>
<p>which is recognized also by GNU Emacs, and</p>
<div class="highlight-python"><div class="highlight"><pre><span class="c"># vim:fileencoding=&lt;encoding-name&gt;</span>
</pre></div>
</div>
<p>which is recognized by Bram Moolenaar&#8217;s VIM. In addition, if the first bytes of
the file are the UTF-8 byte-order mark (<tt class="docutils literal"><span class="pre">'\xef\xbb\xbf'</span></tt>), the declared file
encoding is UTF-8 (this is supported, among others, by Microsoft&#8217;s
<strong>notepad</strong>).</p>
<p>If an encoding is declared, the encoding name must be recognized by Python. The
encoding is used for all lexical analysis, in particular to find the end of a
string, and to interpret the contents of Unicode literals. String literals are
converted to Unicode for syntactical analysis, then converted back to their
original encoding before interpretation starts. The encoding declaration must
appear on a line of its own.</p>
</div>
<div class="section" id="explicit-line-joining">
<span id="explicit-joining"></span><h3>2.1.5. Explicit line joining<a class="headerlink" href="#explicit-line-joining" title="Permalink to this headline">¶</a></h3>
<p id="index-985">Two or more physical lines may be joined into logical lines using backslash
characters (<tt class="docutils literal"><span class="pre">\</span></tt>), as follows: when a physical line ends in a backslash that is
not part of a string literal or comment, it is joined with the following forming
a single logical line, deleting the backslash and the following end-of-line
character.  For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">if</span> <span class="mi">1900</span> <span class="o">&lt;</span> <span class="n">year</span> <span class="o">&lt;</span> <span class="mi">2100</span> <span class="ow">and</span> <span class="mi">1</span> <span class="o">&lt;=</span> <span class="n">month</span> <span class="o">&lt;=</span> <span class="mi">12</span> \
   <span class="ow">and</span> <span class="mi">1</span> <span class="o">&lt;=</span> <span class="n">day</span> <span class="o">&lt;=</span> <span class="mi">31</span> <span class="ow">and</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">hour</span> <span class="o">&lt;</span> <span class="mi">24</span> \
   <span class="ow">and</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">minute</span> <span class="o">&lt;</span> <span class="mi">60</span> <span class="ow">and</span> <span class="mi">0</span> <span class="o">&lt;=</span> <span class="n">second</span> <span class="o">&lt;</span> <span class="mi">60</span><span class="p">:</span>   <span class="c"># Looks like a valid date</span>
        <span class="k">return</span> <span class="mi">1</span>
</pre></div>
</div>
<p>A line ending in a backslash cannot carry a comment.  A backslash does not
continue a comment.  A backslash does not continue a token except for string
literals (i.e., tokens other than string literals cannot be split across
physical lines using a backslash).  A backslash is illegal elsewhere on a line
outside a string literal.</p>
</div>
<div class="section" id="implicit-line-joining">
<span id="implicit-joining"></span><h3>2.1.6. Implicit line joining<a class="headerlink" href="#implicit-line-joining" title="Permalink to this headline">¶</a></h3>
<p>Expressions in parentheses, square brackets or curly braces can be split over
more than one physical line without using backslashes. For example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">month_names</span> <span class="o">=</span> <span class="p">[</span><span class="s">&#39;Januari&#39;</span><span class="p">,</span> <span class="s">&#39;Februari&#39;</span><span class="p">,</span> <span class="s">&#39;Maart&#39;</span><span class="p">,</span>      <span class="c"># These are the</span>
               <span class="s">&#39;April&#39;</span><span class="p">,</span>   <span class="s">&#39;Mei&#39;</span><span class="p">,</span>      <span class="s">&#39;Juni&#39;</span><span class="p">,</span>       <span class="c"># Dutch names</span>
               <span class="s">&#39;Juli&#39;</span><span class="p">,</span>    <span class="s">&#39;Augustus&#39;</span><span class="p">,</span> <span class="s">&#39;September&#39;</span><span class="p">,</span>  <span class="c"># for the months</span>
               <span class="s">&#39;Oktober&#39;</span><span class="p">,</span> <span class="s">&#39;November&#39;</span><span class="p">,</span> <span class="s">&#39;December&#39;</span><span class="p">]</span>   <span class="c"># of the year</span>
</pre></div>
</div>
<p>Implicitly continued lines can carry comments.  The indentation of the
continuation lines is not important.  Blank continuation lines are allowed.
There is no NEWLINE token between implicit continuation lines.  Implicitly
continued lines can also occur within triple-quoted strings (see below); in that
case they cannot carry comments.</p>
</div>
<div class="section" id="blank-lines">
<span id="id3"></span><h3>2.1.7. Blank lines<a class="headerlink" href="#blank-lines" title="Permalink to this headline">¶</a></h3>
<p id="index-986">A logical line that contains only spaces, tabs, formfeeds and possibly a
comment, is ignored (i.e., no NEWLINE token is generated).  During interactive
input of statements, handling of a blank line may differ depending on the
implementation of the read-eval-print loop.  In the standard implementation, an
entirely blank logical line (i.e. one containing not even whitespace or a
comment) terminates a multi-line statement.</p>
</div>
<div class="section" id="indentation">
<span id="id4"></span><h3>2.1.8. Indentation<a class="headerlink" href="#indentation" title="Permalink to this headline">¶</a></h3>
<p id="index-987">Leading whitespace (spaces and tabs) at the beginning of a logical line is used
to compute the indentation level of the line, which in turn is used to determine
the grouping of statements.</p>
<p>First, tabs are replaced (from left to right) by one to eight spaces such that
the total number of characters up to and including the replacement is a multiple
of eight (this is intended to be the same rule as used by Unix).  The total
number of spaces preceding the first non-blank character then determines the
line&#8217;s indentation.  Indentation cannot be split over multiple physical lines
using backslashes; the whitespace up to the first backslash determines the
indentation.</p>
<p><strong>Cross-platform compatibility note:</strong> because of the nature of text editors on
non-UNIX platforms, it is unwise to use a mixture of spaces and tabs for the
indentation in a single source file.  It should also be noted that different
platforms may explicitly limit the maximum indentation level.</p>
<p>A formfeed character may be present at the start of the line; it will be ignored
for the indentation calculations above.  Formfeed characters occurring elsewhere
in the leading whitespace have an undefined effect (for instance, they may reset
the space count to zero).</p>
<p id="index-988">The indentation levels of consecutive lines are used to generate INDENT and
DEDENT tokens, using a stack, as follows.</p>
<p>Before the first line of the file is read, a single zero is pushed on the stack;
this will never be popped off again.  The numbers pushed on the stack will
always be strictly increasing from bottom to top.  At the beginning of each
logical line, the line&#8217;s indentation level is compared to the top of the stack.
If it is equal, nothing happens. If it is larger, it is pushed on the stack, and
one INDENT token is generated.  If it is smaller, it <em>must</em> be one of the
numbers occurring on the stack; all numbers on the stack that are larger are
popped off, and for each number popped off a DEDENT token is generated.  At the
end of the file, a DEDENT token is generated for each number remaining on the
stack that is larger than zero.</p>
<p>Here is an example of a correctly (though confusingly) indented piece of Python
code:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">perm</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
        <span class="c"># Compute the list of all permutations of l</span>
    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">l</span><span class="p">)</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">:</span>
                  <span class="k">return</span> <span class="p">[</span><span class="n">l</span><span class="p">]</span>
    <span class="n">r</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">l</span><span class="p">)):</span>
             <span class="n">s</span> <span class="o">=</span> <span class="n">l</span><span class="p">[:</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">l</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">:]</span>
             <span class="n">p</span> <span class="o">=</span> <span class="n">perm</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
             <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">p</span><span class="p">:</span>
              <span class="n">r</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">l</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">i</span><span class="o">+</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">x</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">r</span>
</pre></div>
</div>
<p>The following example shows various indentation errors:</p>
<div class="highlight-python"><pre> def perm(l):                       # error: first line indented
for i in range(len(l)):             # error: not indented
    s = l[:i] + l[i+1:]
        p = perm(l[:i] + l[i+1:])   # error: unexpected indent
        for x in p:
                r.append(l[i:i+1] + x)
            return r                # error: inconsistent dedent</pre>
</div>
<p>(Actually, the first three errors are detected by the parser; only the last
error is found by the lexical analyzer &#8212; the indentation of <tt class="docutils literal"><span class="pre">return</span> <span class="pre">r</span></tt> does
not match a level popped off the stack.)</p>
</div>
<div class="section" id="whitespace-between-tokens">
<span id="whitespace"></span><h3>2.1.9. Whitespace between tokens<a class="headerlink" href="#whitespace-between-tokens" title="Permalink to this headline">¶</a></h3>
<p>Except at the beginning of a logical line or in string literals, the whitespace
characters space, tab and formfeed can be used interchangeably to separate
tokens.  Whitespace is needed between two tokens only if their concatenation
could otherwise be interpreted as a different token (e.g., ab is one token, but
a b is two tokens).</p>
</div>
</div>
<div class="section" id="other-tokens">
<span id="id5"></span><h2>2.2. Other tokens<a class="headerlink" href="#other-tokens" title="Permalink to this headline">¶</a></h2>
<p>Besides NEWLINE, INDENT and DEDENT, the following categories of tokens exist:
<em>identifiers</em>, <em>keywords</em>, <em>literals</em>, <em>operators</em>, and <em>delimiters</em>. Whitespace
characters (other than line terminators, discussed earlier) are not tokens, but
serve to delimit tokens. Where ambiguity exists, a token comprises the longest
possible string that forms a legal token, when read from left to right.</p>
</div>
<div class="section" id="identifiers">
<span id="identifiers-and-keywords"></span><h2>2.3. Identifiers and keywords<a class="headerlink" href="#identifiers" title="Permalink to this headline">¶</a></h2>
<p id="index-989">Identifiers (also referred to as <em>names</em>) are described by the following lexical
definitions:</p>
<pre>
<strong id="grammar-token-identifier">identifier</strong> ::=  (<a class="reference internal" href="#grammar-token-letter"><tt class="xref docutils literal"><span class="pre">letter</span></tt></a>|&quot;_&quot;) (<a class="reference internal" href="#grammar-token-letter"><tt class="xref docutils literal"><span class="pre">letter</span></tt></a> | <a class="reference internal" href="#grammar-token-digit"><tt class="xref docutils literal"><span class="pre">digit</span></tt></a> | &quot;_&quot;)*
<strong id="grammar-token-letter">letter    </strong> ::=  <a class="reference internal" href="#grammar-token-lowercase"><tt class="xref docutils literal"><span class="pre">lowercase</span></tt></a> | <a class="reference internal" href="#grammar-token-uppercase"><tt class="xref docutils literal"><span class="pre">uppercase</span></tt></a>
<strong id="grammar-token-lowercase">lowercase </strong> ::=  &quot;a&quot;...&quot;z&quot;
<strong id="grammar-token-uppercase">uppercase </strong> ::=  &quot;A&quot;...&quot;Z&quot;
<strong id="grammar-token-digit">digit     </strong> ::=  &quot;0&quot;...&quot;9&quot;
</pre>
<p>Identifiers are unlimited in length.  Case is significant.</p>
<div class="section" id="keywords">
<span id="id6"></span><h3>2.3.1. Keywords<a class="headerlink" href="#keywords" title="Permalink to this headline">¶</a></h3>
<p id="index-990">The following identifiers are used as reserved words, or <em>keywords</em> of the
language, and cannot be used as ordinary identifiers.  They must be spelled
exactly as written here:</p>
<div class="highlight-text"><div class="highlight"><pre>and       del       from      not       while
as        elif      global    or        with
assert    else      if        pass      yield
break     except    import    print
class     exec      in        raise
continue  finally   is        return
def       for       lambda    try
</pre></div>
</div>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.4: </span><a title="None" class="reference external" href="../library/constants.html#None"><tt class="xref xref docutils literal"><span class="pre">None</span></tt></a> became a constant and is now recognized by the compiler as a name
for the built-in object <a title="None" class="reference external" href="../library/constants.html#None"><tt class="xref xref docutils literal"><span class="pre">None</span></tt></a>.  Although it is not a keyword, you cannot
assign a different object to it.</p>
<p class="versionchanged">
<span class="versionmodified">Changed in version 2.5: </span>Both <a class="reference external" href="compound_stmts.html#as"><tt class="xref docutils literal"><span class="pre">as</span></tt></a> and <a class="reference external" href="compound_stmts.html#with"><tt class="xref docutils literal"><span class="pre">with</span></tt></a> are only recognized when the
<tt class="docutils literal"><span class="pre">with_statement</span></tt> future feature has been enabled. It will always be enabled in
Python 2.6.  See section <a class="reference external" href="compound_stmts.html#with"><em>The with statement</em></a> for details.  Note that using <a class="reference external" href="compound_stmts.html#as"><tt class="xref docutils literal"><span class="pre">as</span></tt></a>
and <a class="reference external" href="compound_stmts.html#with"><tt class="xref docutils literal"><span class="pre">with</span></tt></a> as identifiers will always issue a warning, even when the
<tt class="docutils literal"><span class="pre">with_statement</span></tt> future directive is not in effect.</p>
</div>
<div class="section" id="reserved-classes-of-identifiers">
<span id="id-classes"></span><h3>2.3.2. Reserved classes of identifiers<a class="headerlink" href="#reserved-classes-of-identifiers" title="Permalink to this headline">¶</a></h3>
<p>Certain classes of identifiers (besides keywords) have special meanings.  These
classes are identified by the patterns of leading and trailing underscore
characters:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">_*</span></tt></dt>
<dd><p class="first">Not imported by <tt class="docutils literal"><span class="pre">from</span> <span class="pre">module</span> <span class="pre">import</span> <span class="pre">*</span></tt>.  The special identifier <tt class="docutils literal"><span class="pre">_</span></tt> is used
in the interactive interpreter to store the result of the last evaluation; it is
stored in the <a title="The module that provides the built-in namespace." class="reference external" href="../library/__builtin__.html#module-__builtin__"><tt class="xref docutils literal"><span class="pre">__builtin__</span></tt></a> module.  When not in interactive mode, <tt class="docutils literal"><span class="pre">_</span></tt>
has no special meaning and is not defined. See section <a class="reference external" href="simple_stmts.html#import"><em>The import statement</em></a>.</p>
<div class="last admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The name <tt class="docutils literal"><span class="pre">_</span></tt> is often used in conjunction with internationalization;
refer to the documentation for the <a title="Multilingual internationalization services." class="reference external" href="../library/gettext.html#module-gettext"><tt class="xref docutils literal"><span class="pre">gettext</span></tt></a> module for more
information on this convention.</p>
</div>
</dd>
<dt><tt class="docutils literal"><span class="pre">__*__</span></tt></dt>
<dd>System-defined names.  These names are defined by the interpreter and its
implementation (including the standard library); applications should not expect
to define additional names using this convention.  The set of names of this
class defined by Python may be extended in future versions. See section
<a class="reference external" href="datamodel.html#specialnames"><em>Special method names</em></a>.</dd>
<dt><tt class="docutils literal"><span class="pre">__*</span></tt></dt>
<dd>Class-private names.  Names in this category, when used within the context of a
class definition, are re-written to use a mangled form to help avoid name
clashes between &#8220;private&#8221; attributes of base and derived classes. See section
<a class="reference external" href="expressions.html#atom-identifiers"><em>Identifiers (Names)</em></a>.</dd>
</dl>
</div>
</div>
<div class="section" id="literals">
<span id="id7"></span><h2>2.4. Literals<a class="headerlink" href="#literals" title="Permalink to this headline">¶</a></h2>
<p id="index-991">Literals are notations for constant values of some built-in types.</p>
<div class="section" id="string-literals">
<span id="strings"></span><h3>2.4.1. String literals<a class="headerlink" href="#string-literals" title="Permalink to this headline">¶</a></h3>
<p id="index-992">String literals are described by the following lexical definitions:</p>
<pre id="index-993">
<strong id="grammar-token-stringliteral">stringliteral  </strong> ::=  [<a class="reference internal" href="#grammar-token-stringprefix"><tt class="xref docutils literal"><span class="pre">stringprefix</span></tt></a>](<a class="reference internal" href="#grammar-token-shortstring"><tt class="xref docutils literal"><span class="pre">shortstring</span></tt></a> | <a class="reference internal" href="#grammar-token-longstring"><tt class="xref docutils literal"><span class="pre">longstring</span></tt></a>)
<strong id="grammar-token-stringprefix">stringprefix   </strong> ::=  &quot;r&quot; | &quot;u&quot; | &quot;ur&quot; | &quot;R&quot; | &quot;U&quot; | &quot;UR&quot; | &quot;Ur&quot; | &quot;uR&quot;
<strong id="grammar-token-shortstring">shortstring    </strong> ::=  &quot;'&quot; <a class="reference internal" href="#grammar-token-shortstringitem"><tt class="xref docutils literal"><span class="pre">shortstringitem</span></tt></a>* &quot;'&quot; | '&quot;' <a class="reference internal" href="#grammar-token-shortstringitem"><tt class="xref docutils literal"><span class="pre">shortstringitem</span></tt></a>* '&quot;'
<strong id="grammar-token-longstring">longstring     </strong> ::=  &quot;'''&quot; <a class="reference internal" href="#grammar-token-longstringitem"><tt class="xref docutils literal"><span class="pre">longstringitem</span></tt></a>* &quot;'''&quot;
                     | '&quot;&quot;&quot;' <a class="reference internal" href="#grammar-token-longstringitem"><tt class="xref docutils literal"><span class="pre">longstringitem</span></tt></a>* '&quot;&quot;&quot;'
<strong id="grammar-token-shortstringitem">shortstringitem</strong> ::=  <a class="reference internal" href="#grammar-token-shortstringchar"><tt class="xref docutils literal"><span class="pre">shortstringchar</span></tt></a> | <a class="reference internal" href="#grammar-token-escapeseq"><tt class="xref docutils literal"><span class="pre">escapeseq</span></tt></a>
<strong id="grammar-token-longstringitem">longstringitem </strong> ::=  <a class="reference internal" href="#grammar-token-longstringchar"><tt class="xref docutils literal"><span class="pre">longstringchar</span></tt></a> | <a class="reference internal" href="#grammar-token-escapeseq"><tt class="xref docutils literal"><span class="pre">escapeseq</span></tt></a>
<strong id="grammar-token-shortstringchar">shortstringchar</strong> ::=  &lt;any source character except &quot;\&quot; or newline or the quote&gt;
<strong id="grammar-token-longstringchar">longstringchar </strong> ::=  &lt;any source character except &quot;\&quot;&gt;
<strong id="grammar-token-escapeseq">escapeseq      </strong> ::=  &quot;\&quot; &lt;any ASCII character&gt;
</pre>
<p>One syntactic restriction not indicated by these productions is that whitespace
is not allowed between the <a class="reference internal" href="#grammar-token-stringprefix"><strong class="xref">stringprefix</strong></a> and the rest of the string
literal. The source character set is defined by the encoding declaration; it is
ASCII if no encoding declaration is given in the source file; see section
<a class="reference internal" href="#encodings"><em>Encoding declarations</em></a>.</p>
<p id="index-994">In plain English: String literals can be enclosed in matching single quotes
(<tt class="docutils literal"><span class="pre">'</span></tt>) or double quotes (<tt class="docutils literal"><span class="pre">&quot;</span></tt>).  They can also be enclosed in matching groups
of three single or double quotes (these are generally referred to as
<em>triple-quoted strings</em>).  The backslash (<tt class="docutils literal"><span class="pre">\</span></tt>) character is used to escape
characters that otherwise have a special meaning, such as newline, backslash
itself, or the quote character.  String literals may optionally be prefixed with
a letter <tt class="docutils literal"><span class="pre">'r'</span></tt> or <tt class="docutils literal"><span class="pre">'R'</span></tt>; such strings are called <em>raw strings</em> and use
different rules for interpreting backslash escape sequences.  A prefix of
<tt class="docutils literal"><span class="pre">'u'</span></tt> or <tt class="docutils literal"><span class="pre">'U'</span></tt> makes the string a Unicode string.  Unicode strings use the
Unicode character set as defined by the Unicode Consortium and ISO 10646.  Some
additional escape sequences, described below, are available in Unicode strings.
The two prefix characters may be combined; in this case, <tt class="docutils literal"><span class="pre">'u'</span></tt> must appear
before <tt class="docutils literal"><span class="pre">'r'</span></tt>.</p>
<p>In triple-quoted strings, unescaped newlines and quotes are allowed (and are
retained), except that three unescaped quotes in a row terminate the string.  (A
&#8220;quote&#8221; is the character used to open the string, i.e. either <tt class="docutils literal"><span class="pre">'</span></tt> or <tt class="docutils literal"><span class="pre">&quot;</span></tt>.)</p>
<p id="index-995">Unless an <tt class="docutils literal"><span class="pre">'r'</span></tt> or <tt class="docutils literal"><span class="pre">'R'</span></tt> prefix is present, escape sequences in strings are
interpreted according to rules similar to those used by Standard C.  The
recognized escape sequences are:</p>
<table border="1" class="docutils">
<colgroup>
<col width="30%" />
<col width="58%" />
<col width="12%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Escape Sequence</th>
<th class="head">Meaning</th>
<th class="head">Notes</th>
</tr>
</thead>
<tbody valign="top">
<tr><td><tt class="docutils literal"><span class="pre">\newline</span></tt></td>
<td>Ignored</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\\</span></tt></td>
<td>Backslash (<tt class="docutils literal"><span class="pre">\</span></tt>)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\'</span></tt></td>
<td>Single quote (<tt class="docutils literal"><span class="pre">'</span></tt>)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\&quot;</span></tt></td>
<td>Double quote (<tt class="docutils literal"><span class="pre">&quot;</span></tt>)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\a</span></tt></td>
<td>ASCII Bell (BEL)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\b</span></tt></td>
<td>ASCII Backspace (BS)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\f</span></tt></td>
<td>ASCII Formfeed (FF)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\n</span></tt></td>
<td>ASCII Linefeed (LF)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\N{name}</span></tt></td>
<td>Character named <em>name</em> in the
Unicode database (Unicode only)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\r</span></tt></td>
<td>ASCII Carriage Return (CR)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\t</span></tt></td>
<td>ASCII Horizontal Tab (TAB)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\uxxxx</span></tt></td>
<td>Character with 16-bit hex value
<em>xxxx</em> (Unicode only)</td>
<td>(1)</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\Uxxxxxxxx</span></tt></td>
<td>Character with 32-bit hex value
<em>xxxxxxxx</em> (Unicode only)</td>
<td>(2)</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\v</span></tt></td>
<td>ASCII Vertical Tab (VT)</td>
<td>&nbsp;</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\ooo</span></tt></td>
<td>Character with octal value
<em>ooo</em></td>
<td>(3,5)</td>
</tr>
<tr><td><tt class="docutils literal"><span class="pre">\xhh</span></tt></td>
<td>Character with hex value <em>hh</em></td>
<td>(4,5)</td>
</tr>
</tbody>
</table>
<p id="index-996">Notes:</p>
<ol class="arabic simple">
<li>Individual code units which form parts of a surrogate pair can be encoded using
this escape sequence.</li>
<li>Any Unicode character can be encoded this way, but characters outside the Basic
Multilingual Plane (BMP) will be encoded using a surrogate pair if Python is
compiled to use 16-bit code units (the default).  Individual code units which
form parts of a surrogate pair can be encoded using this escape sequence.</li>
<li>As in Standard C, up to three octal digits are accepted.</li>
<li>Unlike in Standard C, exactly two hex digits are required.</li>
<li>In a string literal, hexadecimal and octal escapes denote the byte with the
given value; it is not necessary that the byte encodes a character in the source
character set. In a Unicode literal, these escapes denote a Unicode character
with the given value.</li>
</ol>
<p id="index-997">Unlike Standard C, all unrecognized escape sequences are left in the string
unchanged, i.e., <em>the backslash is left in the string</em>.  (This behavior is
useful when debugging: if an escape sequence is mistyped, the resulting output
is more easily recognized as broken.)  It is also important to note that the
escape sequences marked as &#8220;(Unicode only)&#8221; in the table above fall into the
category of unrecognized escapes for non-Unicode string literals.</p>
<p>When an <tt class="docutils literal"><span class="pre">'r'</span></tt> or <tt class="docutils literal"><span class="pre">'R'</span></tt> prefix is present, a character following a backslash
is included in the string without change, and <em>all backslashes are left in the
string</em>.  For example, the string literal <tt class="docutils literal"><span class="pre">r&quot;\n&quot;</span></tt> consists of two characters:
a backslash and a lowercase <tt class="docutils literal"><span class="pre">'n'</span></tt>.  String quotes can be escaped with a
backslash, but the backslash remains in the string; for example, <tt class="docutils literal"><span class="pre">r&quot;\&quot;&quot;</span></tt> is a
valid string literal consisting of two characters: a backslash and a double
quote; <tt class="docutils literal"><span class="pre">r&quot;\&quot;</span></tt> is not a valid string literal (even a raw string cannot end in
an odd number of backslashes).  Specifically, <em>a raw string cannot end in a
single backslash</em> (since the backslash would escape the following quote
character).  Note also that a single backslash followed by a newline is
interpreted as those two characters as part of the string, <em>not</em> as a line
continuation.</p>
<p>When an <tt class="docutils literal"><span class="pre">'r'</span></tt> or <tt class="docutils literal"><span class="pre">'R'</span></tt> prefix is used in conjunction with a <tt class="docutils literal"><span class="pre">'u'</span></tt> or
<tt class="docutils literal"><span class="pre">'U'</span></tt> prefix, then the <tt class="docutils literal"><span class="pre">\uXXXX</span></tt> and <tt class="docutils literal"><span class="pre">\UXXXXXXXX</span></tt> escape sequences are
processed while  <em>all other backslashes are left in the string</em>. For example,
the string literal <tt class="docutils literal"><span class="pre">ur&quot;\u0062\n&quot;</span></tt> consists of three Unicode characters: &#8216;LATIN
SMALL LETTER B&#8217;, &#8216;REVERSE SOLIDUS&#8217;, and &#8216;LATIN SMALL LETTER N&#8217;. Backslashes can
be escaped with a preceding backslash; however, both remain in the string.  As a
result, <tt class="docutils literal"><span class="pre">\uXXXX</span></tt> escape sequences are only recognized when there are an odd
number of backslashes.</p>
</div>
<div class="section" id="string-literal-concatenation">
<span id="string-catenation"></span><h3>2.4.2. String literal concatenation<a class="headerlink" href="#string-literal-concatenation" title="Permalink to this headline">¶</a></h3>
<p>Multiple adjacent string literals (delimited by whitespace), possibly using
different quoting conventions, are allowed, and their meaning is the same as
their concatenation.  Thus, <tt class="docutils literal"><span class="pre">&quot;hello&quot;</span> <span class="pre">'world'</span></tt> is equivalent to
<tt class="docutils literal"><span class="pre">&quot;helloworld&quot;</span></tt>.  This feature can be used to reduce the number of backslashes
needed, to split long strings conveniently across long lines, or even to add
comments to parts of strings, for example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s">&quot;[A-Za-z_]&quot;</span>       <span class="c"># letter or underscore</span>
           <span class="s">&quot;[A-Za-z0-9_]*&quot;</span>   <span class="c"># letter, digit or underscore</span>
          <span class="p">)</span>
</pre></div>
</div>
<p>Note that this feature is defined at the syntactical level, but implemented at
compile time.  The &#8216;+&#8217; operator must be used to concatenate string expressions
at run time.  Also note that literal concatenation can use different quoting
styles for each component (even mixing raw strings and triple quoted strings).</p>
</div>
<div class="section" id="numeric-literals">
<span id="numbers"></span><h3>2.4.3. Numeric literals<a class="headerlink" href="#numeric-literals" title="Permalink to this headline">¶</a></h3>
<p id="index-998">There are four types of numeric literals: plain integers, long integers,
floating point numbers, and imaginary numbers.  There are no complex literals
(complex numbers can be formed by adding a real number and an imaginary number).</p>
<p>Note that numeric literals do not include a sign; a phrase like <tt class="docutils literal"><span class="pre">-1</span></tt> is
actually an expression composed of the unary operator &#8216;<tt class="docutils literal"><span class="pre">-</span></tt>&#8216; and the literal
<tt class="docutils literal"><span class="pre">1</span></tt>.</p>
</div>
<div class="section" id="integer-and-long-integer-literals">
<span id="integers"></span><h3>2.4.4. Integer and long integer literals<a class="headerlink" href="#integer-and-long-integer-literals" title="Permalink to this headline">¶</a></h3>
<p>Integer and long integer literals are described by the following lexical
definitions:</p>
<pre>
<strong id="grammar-token-longinteger">longinteger   </strong> ::=  <a class="reference internal" href="#grammar-token-integer"><tt class="xref docutils literal"><span class="pre">integer</span></tt></a> (&quot;l&quot; | &quot;L&quot;)
<strong id="grammar-token-integer">integer       </strong> ::=  <a class="reference internal" href="#grammar-token-decimalinteger"><tt class="xref docutils literal"><span class="pre">decimalinteger</span></tt></a> | <a class="reference internal" href="#grammar-token-octinteger"><tt class="xref docutils literal"><span class="pre">octinteger</span></tt></a> | <a class="reference internal" href="#grammar-token-hexinteger"><tt class="xref docutils literal"><span class="pre">hexinteger</span></tt></a> | <a class="reference internal" href="#grammar-token-bininteger"><tt class="xref docutils literal"><span class="pre">bininteger</span></tt></a>
<strong id="grammar-token-decimalinteger">decimalinteger</strong> ::=  <a class="reference internal" href="#grammar-token-nonzerodigit"><tt class="xref docutils literal"><span class="pre">nonzerodigit</span></tt></a> <a class="reference internal" href="#grammar-token-digit"><tt class="xref docutils literal"><span class="pre">digit</span></tt></a>* | &quot;0&quot;
<strong id="grammar-token-octinteger">octinteger    </strong> ::=  &quot;0&quot; (&quot;o&quot; | &quot;O&quot;) <a class="reference internal" href="#grammar-token-octdigit"><tt class="xref docutils literal"><span class="pre">octdigit</span></tt></a>+ | &quot;0&quot; <a class="reference internal" href="#grammar-token-octdigit"><tt class="xref docutils literal"><span class="pre">octdigit</span></tt></a>+
<strong id="grammar-token-hexinteger">hexinteger    </strong> ::=  &quot;0&quot; (&quot;x&quot; | &quot;X&quot;) <a class="reference internal" href="#grammar-token-hexdigit"><tt class="xref docutils literal"><span class="pre">hexdigit</span></tt></a>+
<strong id="grammar-token-bininteger">bininteger    </strong> ::=  &quot;0&quot; (&quot;b&quot; | &quot;B&quot;) <a class="reference internal" href="#grammar-token-bindigit"><tt class="xref docutils literal"><span class="pre">bindigit</span></tt></a>+
<strong id="grammar-token-nonzerodigit">nonzerodigit  </strong> ::=  &quot;1&quot;...&quot;9&quot;
<strong id="grammar-token-octdigit">octdigit      </strong> ::=  &quot;0&quot;...&quot;7&quot;
<strong id="grammar-token-bindigit">bindigit      </strong> ::=  &quot;0&quot; | &quot;1&quot;
<strong id="grammar-token-hexdigit">hexdigit      </strong> ::=  <a class="reference internal" href="#grammar-token-digit"><tt class="xref docutils literal"><span class="pre">digit</span></tt></a> | &quot;a&quot;...&quot;f&quot; | &quot;A&quot;...&quot;F&quot;
</pre>
<p>Although both lower case <tt class="docutils literal"><span class="pre">'l'</span></tt> and upper case <tt class="docutils literal"><span class="pre">'L'</span></tt> are allowed as suffix
for long integers, it is strongly recommended to always use <tt class="docutils literal"><span class="pre">'L'</span></tt>, since the
letter <tt class="docutils literal"><span class="pre">'l'</span></tt> looks too much like the digit <tt class="docutils literal"><span class="pre">'1'</span></tt>.</p>
<p>Plain integer literals that are above the largest representable plain integer
(e.g., 2147483647 when using 32-bit arithmetic) are accepted as if they were
long integers instead. <a class="footnote-reference" href="#id11" id="id8">[1]</a>  There is no limit for long integer literals apart
from what can be stored in available memory.</p>
<p>Some examples of plain integer literals (first row) and long integer literals
(second and third rows):</p>
<div class="highlight-python"><pre>7     2147483647                        0177
3L    79228162514264337593543950336L    0377L   0x100000000L
      79228162514264337593543950336             0xdeadbeef</pre>
</div>
</div>
<div class="section" id="floating-point-literals">
<span id="floating"></span><h3>2.4.5. Floating point literals<a class="headerlink" href="#floating-point-literals" title="Permalink to this headline">¶</a></h3>
<p>Floating point literals are described by the following lexical definitions:</p>
<pre>
<strong id="grammar-token-floatnumber">floatnumber  </strong> ::=  <a class="reference internal" href="#grammar-token-pointfloat"><tt class="xref docutils literal"><span class="pre">pointfloat</span></tt></a> | <a class="reference internal" href="#grammar-token-exponentfloat"><tt class="xref docutils literal"><span class="pre">exponentfloat</span></tt></a>
<strong id="grammar-token-pointfloat">pointfloat   </strong> ::=  [<a class="reference internal" href="#grammar-token-intpart"><tt class="xref docutils literal"><span class="pre">intpart</span></tt></a>] <a class="reference internal" href="#grammar-token-fraction"><tt class="xref docutils literal"><span class="pre">fraction</span></tt></a> | <a class="reference internal" href="#grammar-token-intpart"><tt class="xref docutils literal"><span class="pre">intpart</span></tt></a> &quot;.&quot;
<strong id="grammar-token-exponentfloat">exponentfloat</strong> ::=  (<a class="reference internal" href="#grammar-token-intpart"><tt class="xref docutils literal"><span class="pre">intpart</span></tt></a> | <a class="reference internal" href="#grammar-token-pointfloat"><tt class="xref docutils literal"><span class="pre">pointfloat</span></tt></a>) <a class="reference internal" href="#grammar-token-exponent"><tt class="xref docutils literal"><span class="pre">exponent</span></tt></a>
<strong id="grammar-token-intpart">intpart      </strong> ::=  <a class="reference internal" href="#grammar-token-digit"><tt class="xref docutils literal"><span class="pre">digit</span></tt></a>+
<strong id="grammar-token-fraction">fraction     </strong> ::=  &quot;.&quot; <a class="reference internal" href="#grammar-token-digit"><tt class="xref docutils literal"><span class="pre">digit</span></tt></a>+
<strong id="grammar-token-exponent">exponent     </strong> ::=  (&quot;e&quot; | &quot;E&quot;) [&quot;+&quot; | &quot;-&quot;] <a class="reference internal" href="#grammar-token-digit"><tt class="xref docutils literal"><span class="pre">digit</span></tt></a>+
</pre>
<p>Note that the integer and exponent parts of floating point numbers can look like
octal integers, but are interpreted using radix 10.  For example, <tt class="docutils literal"><span class="pre">077e010</span></tt> is
legal, and denotes the same number as <tt class="docutils literal"><span class="pre">77e10</span></tt>. The allowed range of floating
point literals is implementation-dependent. Some examples of floating point
literals:</p>
<div class="highlight-python"><pre>3.14    10.    .001    1e100    3.14e-10    0e0</pre>
</div>
<p>Note that numeric literals do not include a sign; a phrase like <tt class="docutils literal"><span class="pre">-1</span></tt> is
actually an expression composed of the unary operator <tt class="docutils literal"><span class="pre">-</span></tt> and the literal
<tt class="docutils literal"><span class="pre">1</span></tt>.</p>
</div>
<div class="section" id="imaginary-literals">
<span id="imaginary"></span><h3>2.4.6. Imaginary literals<a class="headerlink" href="#imaginary-literals" title="Permalink to this headline">¶</a></h3>
<p>Imaginary literals are described by the following lexical definitions:</p>
<pre>
<strong id="grammar-token-imagnumber">imagnumber</strong> ::=  (<a class="reference internal" href="#grammar-token-floatnumber"><tt class="xref docutils literal"><span class="pre">floatnumber</span></tt></a> | <a class="reference internal" href="#grammar-token-intpart"><tt class="xref docutils literal"><span class="pre">intpart</span></tt></a>) (&quot;j&quot; | &quot;J&quot;)
</pre>
<p>An imaginary literal yields a complex number with a real part of 0.0.  Complex
numbers are represented as a pair of floating point numbers and have the same
restrictions on their range.  To create a complex number with a nonzero real
part, add a floating point number to it, e.g., <tt class="docutils literal"><span class="pre">(3+4j)</span></tt>.  Some examples of
imaginary literals:</p>
<div class="highlight-python"><pre>3.14j   10.j    10j     .001j   1e100j  3.14e-10j</pre>
</div>
</div>
</div>
<div class="section" id="operators">
<span id="id9"></span><h2>2.5. Operators<a class="headerlink" href="#operators" title="Permalink to this headline">¶</a></h2>
<p id="index-999">The following tokens are operators:</p>
<div class="highlight-python"><pre>+       -       *       **      /       //      %
&lt;&lt;      &gt;&gt;      &amp;       |       ^       ~
&lt;       &gt;       &lt;=      &gt;=      ==      !=      &lt;&gt;</pre>
</div>
<p>The comparison operators <tt class="docutils literal"><span class="pre">&lt;&gt;</span></tt> and <tt class="docutils literal"><span class="pre">!=</span></tt> are alternate spellings of the same
operator.  <tt class="docutils literal"><span class="pre">!=</span></tt> is the preferred spelling; <tt class="docutils literal"><span class="pre">&lt;&gt;</span></tt> is obsolescent.</p>
</div>
<div class="section" id="delimiters">
<span id="id10"></span><h2>2.6. Delimiters<a class="headerlink" href="#delimiters" title="Permalink to this headline">¶</a></h2>
<p id="index-1000">The following tokens serve as delimiters in the grammar:</p>
<div class="highlight-python"><pre>(       )       [       ]       {       }      @
,       :       .       `       =       ;
+=      -=      *=      /=      //=     %=
&amp;=      |=      ^=      &gt;&gt;=     &lt;&lt;=     **=</pre>
</div>
<p>The period can also occur in floating-point and imaginary literals.  A sequence
of three periods has a special meaning as an ellipsis in slices. The second half
of the list, the augmented assignment operators, serve lexically as delimiters,
but also perform an operation.</p>
<p>The following printing ASCII characters have special meaning as part of other
tokens or are otherwise significant to the lexical analyzer:</p>
<div class="highlight-python"><pre>'       "       #       \</pre>
</div>
<p id="index-1001">The following printing ASCII characters are not used in Python.  Their
occurrence outside string literals and comments is an unconditional error:</p>
<div class="highlight-python"><pre>$       ?</pre>
</div>
<p class="rubric">Footnotes</p>
<table class="docutils footnote" frame="void" id="id11" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a class="fn-backref" href="#id8">[1]</a></td><td>In versions of Python prior to 2.4, octal and hexadecimal literals in the range
just above the largest representable plain integer but below the largest
unsigned 32-bit number (on a machine using 32-bit arithmetic), 4294967296, were
taken as the negative plain integer obtained by subtracting 4294967296 from
their unsigned value.</td></tr>
</tbody>
</table>
</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="#">2. Lexical analysis</a><ul>
<li><a class="reference external" href="#line-structure">2.1. Line structure</a><ul>
<li><a class="reference external" href="#logical-lines">2.1.1. Logical lines</a></li>
<li><a class="reference external" href="#physical-lines">2.1.2. Physical lines</a></li>
<li><a class="reference external" href="#comments">2.1.3. Comments</a></li>
<li><a class="reference external" href="#encoding-declarations">2.1.4. Encoding declarations</a></li>
<li><a class="reference external" href="#explicit-line-joining">2.1.5. Explicit line joining</a></li>
<li><a class="reference external" href="#implicit-line-joining">2.1.6. Implicit line joining</a></li>
<li><a class="reference external" href="#blank-lines">2.1.7. Blank lines</a></li>
<li><a class="reference external" href="#indentation">2.1.8. Indentation</a></li>
<li><a class="reference external" href="#whitespace-between-tokens">2.1.9. Whitespace between tokens</a></li>
</ul>
</li>
<li><a class="reference external" href="#other-tokens">2.2. Other tokens</a></li>
<li><a class="reference external" href="#identifiers">2.3. Identifiers and keywords</a><ul>
<li><a class="reference external" href="#keywords">2.3.1. Keywords</a></li>
<li><a class="reference external" href="#reserved-classes-of-identifiers">2.3.2. Reserved classes of identifiers</a></li>
</ul>
</li>
<li><a class="reference external" href="#literals">2.4. Literals</a><ul>
<li><a class="reference external" href="#string-literals">2.4.1. String literals</a></li>
<li><a class="reference external" href="#string-literal-concatenation">2.4.2. String literal concatenation</a></li>
<li><a class="reference external" href="#numeric-literals">2.4.3. Numeric literals</a></li>
<li><a class="reference external" href="#integer-and-long-integer-literals">2.4.4. Integer and long integer literals</a></li>
<li><a class="reference external" href="#floating-point-literals">2.4.5. Floating point literals</a></li>
<li><a class="reference external" href="#imaginary-literals">2.4.6. Imaginary literals</a></li>
</ul>
</li>
<li><a class="reference external" href="#operators">2.5. Operators</a></li>
<li><a class="reference external" href="#delimiters">2.6. Delimiters</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="introduction.html"
                                  title="previous chapter">1. Introduction</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="datamodel.html"
                                  title="next chapter">3. Data model</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="../_sources/reference/lexical_analysis.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="datamodel.html" title="3. Data model"
             >next</a> |</li>
        <li class="right" >
          <a href="introduction.html" title="1. Introduction"
             >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.5 documentation</a> &raquo;</li>

          <li><a href="index.html" >The Python Language Reference</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 Mar 19, 2010.
    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.5.
    </div>

  </body>
</html>