<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Python Tutorial</title> <META NAME="description" CONTENT="Python Tutorial"> <META NAME="keywords" CONTENT="tut"> <META NAME="resource-type" CONTENT="document"> <META NAME="distribution" CONTENT="global"> <meta http-equiv="Content-Type" content="text/html; charset="> <link rel="STYLESHEET" href="tut.css"> <link rel="first" href="tut.html"> <link rel="contents" href="contents.html" title="Contents"> <LINK REL="next" HREF="node1.html"> </head> <body> <DIV CLASS="navigation"> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><img src="../icons/blank.gif" border="0" height="32" alt="" width="32"></td> <td><A HREF="../index.html"><img src="../icons/up.gif" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A HREF="node1.html"><img src="../icons/next.gif" border="0" height="32" alt="Next Page" width="32"></A></td> <td align="center" width="100%">Python Tutorial</td> <td><A HREF="node2.html"><img src="../icons/contents.gif" border="0" height="32" alt="Contents" width="32"></A></td> <td><img src="../icons/blank.gif" border="0" height="32" alt="" width="32"></td> <td><img src="../icons/blank.gif" border="0" height="32" alt="" width="32"></td> </tr></table> <b class="navlabel">Up:</b> <a class="sectref" HREF="../index.html">Python Documentation Index</A> <b class="navlabel">Next:</b> <a class="sectref" HREF="node1.html">Front Matter</A> <br><hr> </DIV> <!--End of Navigation Panel--> <P> <div class="titlepage"> <center> <h1>Python Tutorial</h1> <p><b><font size="+2">Guido van Rossum <BR> Fred L. Drake, Jr., editor</font></b></p> <p> <b>PythonLabs</b> <BR> Email: <span class="email">python-docs@python.org</span> </p> <p><strong>Release 2.2</strong><br> <strong>December 21, 2001</strong></p> <p> </center> </div> <P> <p><hr> <!--Table of Child-Links--> <A NAME="CHILD_LINKS"></a> <UL CLASS="ChildLinks"> <LI><A href="node1.html">Front Matter</a> <LI><A href="node2.html">Contents</a> <LI><A href="node3.html">1. Whetting Your Appetite</a> <UL> <LI><A href="node3.html#SECTION003100000000000000000">1.1 Where From Here</a> </ul> <LI><A href="node4.html">2. Using the Python Interpreter</a> <UL> <LI><A href="node4.html#SECTION004100000000000000000">2.1 Invoking the Interpreter</a> <UL> <LI><A href="node4.html#SECTION004110000000000000000">2.1.1 Argument Passing</a> <LI><A href="node4.html#SECTION004120000000000000000">2.1.2 Interactive Mode</a> </ul> <LI><A href="node4.html#SECTION004200000000000000000">2.2 The Interpreter and Its Environment</a> <UL> <LI><A href="node4.html#SECTION004210000000000000000">2.2.1 Error Handling</a> <LI><A href="node4.html#SECTION004220000000000000000">2.2.2 Executable Python Scripts</a> <LI><A href="node4.html#SECTION004230000000000000000">2.2.3 The Interactive Startup File</a> </ul> </ul> <LI><A href="node5.html">3. An Informal Introduction to Python</a> <UL> <LI><A href="node5.html#SECTION005100000000000000000">3.1 Using Python as a Calculator</a> <UL> <LI><A href="node5.html#SECTION005110000000000000000">3.1.1 Numbers</a> <LI><A href="node5.html#SECTION005120000000000000000">3.1.2 Strings</a> <LI><A href="node5.html#SECTION005130000000000000000">3.1.3 Unicode Strings</a> <LI><A href="node5.html#SECTION005140000000000000000">3.1.4 Lists</a> </ul> <LI><A href="node5.html#SECTION005200000000000000000">3.2 First Steps Towards Programming</a> </ul> <LI><A href="node6.html">4. More Control Flow Tools</a> <UL> <LI><A href="node6.html#SECTION006100000000000000000">4.1 <tt class="keyword">if</tt> Statements</a> <LI><A href="node6.html#SECTION006200000000000000000">4.2 <tt class="keyword">for</tt> Statements</a> <LI><A href="node6.html#SECTION006300000000000000000">4.3 The <tt class="function">range()</tt> Function</a> <LI><A href="node6.html#SECTION006400000000000000000">4.4 <tt class="keyword">break</tt> and <tt class="keyword">continue</tt> Statements, and <tt class="keyword">else</tt> Clauses on Loops</a> <LI><A href="node6.html#SECTION006500000000000000000">4.5 <tt class="keyword">pass</tt> Statements</a> <LI><A href="node6.html#SECTION006600000000000000000">4.6 Defining Functions</a> <LI><A href="node6.html#SECTION006700000000000000000">4.7 More on Defining Functions</a> <UL> <LI><A href="node6.html#SECTION006710000000000000000">4.7.1 Default Argument Values</a> <LI><A href="node6.html#SECTION006720000000000000000">4.7.2 Keyword Arguments</a> <LI><A href="node6.html#SECTION006730000000000000000">4.7.3 Arbitrary Argument Lists</a> <LI><A href="node6.html#SECTION006740000000000000000">4.7.4 Lambda Forms</a> <LI><A href="node6.html#SECTION006750000000000000000">4.7.5 Documentation Strings</a> </ul> </ul> <LI><A href="node7.html">5. Data Structures</a> <UL> <LI><A href="node7.html#SECTION007100000000000000000">5.1 More on Lists</a> <UL> <LI><A href="node7.html#SECTION007110000000000000000">5.1.1 Using Lists as Stacks</a> <LI><A href="node7.html#SECTION007120000000000000000">5.1.2 Using Lists as Queues</a> <LI><A href="node7.html#SECTION007130000000000000000">5.1.3 Functional Programming Tools</a> <LI><A href="node7.html#SECTION007140000000000000000">5.1.4 List Comprehensions</a> </ul> <LI><A href="node7.html#SECTION007200000000000000000">5.2 The <tt class="keyword">del</tt> statement</a> <LI><A href="node7.html#SECTION007300000000000000000">5.3 Tuples and Sequences</a> <LI><A href="node7.html#SECTION007400000000000000000">5.4 Dictionaries</a> <LI><A href="node7.html#SECTION007500000000000000000">5.5 More on Conditions</a> <LI><A href="node7.html#SECTION007600000000000000000">5.6 Comparing Sequences and Other Types</a> </ul> <LI><A href="node8.html">6. Modules</a> <UL> <LI><A href="node8.html#SECTION008100000000000000000">6.1 More on Modules</a> <UL> <LI><A href="node8.html#SECTION008110000000000000000">6.1.1 The Module Search Path</a> <LI><A href="node8.html#SECTION008120000000000000000">6.1.2 ``Compiled'' Python files</a> </ul> <LI><A href="node8.html#SECTION008200000000000000000">6.2 Standard Modules</a> <LI><A href="node8.html#SECTION008300000000000000000">6.3 The <tt class="function">dir()</tt> Function</a> <LI><A href="node8.html#SECTION008400000000000000000">6.4 Packages</a> <UL> <LI><A href="node8.html#SECTION008410000000000000000">6.4.1 Importing * From a Package</a> <LI><A href="node8.html#SECTION008420000000000000000">6.4.2 Intra-package References</a> </ul> </ul> <LI><A href="node9.html">7. Input and Output</a> <UL> <LI><A href="node9.html#SECTION009100000000000000000">7.1 Fancier Output Formatting</a> <LI><A href="node9.html#SECTION009200000000000000000">7.2 Reading and Writing Files</a> <UL> <LI><A href="node9.html#SECTION009210000000000000000">7.2.1 Methods of File Objects</a> <LI><A href="node9.html#SECTION009220000000000000000">7.2.2 The <tt class="module">pickle</tt> Module</a> </ul> </ul> <LI><A href="node10.html">8. Errors and Exceptions</a> <UL> <LI><A href="node10.html#SECTION0010100000000000000000">8.1 Syntax Errors</a> <LI><A href="node10.html#SECTION0010200000000000000000">8.2 Exceptions</a> <LI><A href="node10.html#SECTION0010300000000000000000">8.3 Handling Exceptions</a> <LI><A href="node10.html#SECTION0010400000000000000000">8.4 Raising Exceptions</a> <LI><A href="node10.html#SECTION0010500000000000000000">8.5 User-defined Exceptions</a> <LI><A href="node10.html#SECTION0010600000000000000000">8.6 Defining Clean-up Actions</a> </ul> <LI><A href="node11.html">9. Classes</a> <UL> <LI><A href="node11.html#SECTION0011100000000000000000">9.1 A Word About Terminology</a> <LI><A href="node11.html#SECTION0011200000000000000000">9.2 Python Scopes and Name Spaces</a> <LI><A href="node11.html#SECTION0011300000000000000000">9.3 A First Look at Classes</a> <UL> <LI><A href="node11.html#SECTION0011310000000000000000">9.3.1 Class Definition Syntax</a> <LI><A href="node11.html#SECTION0011320000000000000000">9.3.2 Class Objects</a> <LI><A href="node11.html#SECTION0011330000000000000000">9.3.3 Instance Objects</a> <LI><A href="node11.html#SECTION0011340000000000000000">9.3.4 Method Objects</a> </ul> <LI><A href="node11.html#SECTION0011400000000000000000">9.4 Random Remarks</a> <LI><A href="node11.html#SECTION0011500000000000000000">9.5 Inheritance</a> <UL> <LI><A href="node11.html#SECTION0011510000000000000000">9.5.1 Multiple Inheritance</a> </ul> <LI><A href="node11.html#SECTION0011600000000000000000">9.6 Private Variables</a> <LI><A href="node11.html#SECTION0011700000000000000000">9.7 Odds and Ends</a> <UL> <LI><A href="node11.html#SECTION0011710000000000000000">9.7.1 Exceptions Can Be Classes</a> </ul> </ul> <LI><A href="node12.html">10. What Now?</a> <LI><A href="node13.html">A. Interactive Input Editing and History Substitution</a> <UL> <LI><A href="node13.html#SECTION0013100000000000000000">A.1 Line Editing</a> <LI><A href="node13.html#SECTION0013200000000000000000">A.2 History Substitution</a> <LI><A href="node13.html#SECTION0013300000000000000000">A.3 Key Bindings</a> <LI><A href="node13.html#SECTION0013400000000000000000">A.4 Commentary</a> </ul> <LI><A href="node14.html">B. Floating Point Arithmetic: Issues and Limitations</a> <UL> <LI><A href="node14.html#SECTION0014100000000000000000">B.1 Representation Error</a> </ul> <LI><A href="node15.html">C. History and License</a> <UL> <LI><A href="node15.html#SECTION0015100000000000000000">C.1 History of the software</a> <LI><A href="node15.html#SECTION0015200000000000000000">C.2 Terms and conditions for accessing or otherwise using Python</a> </ul> <LI><A href="node16.html">About this document ...</a> </ul> <!--End of Table of Child-Links--> <DIV CLASS="navigation"> <p><hr> <table align="center" width="100%" cellpadding="0" cellspacing="2"> <tr> <td><img src="../icons/blank.gif" border="0" height="32" alt="" width="32"></td> <td><A HREF="../index.html"><img src="../icons/up.gif" border="0" height="32" alt="Up One Level" width="32"></A></td> <td><A HREF="node1.html"><img src="../icons/next.gif" border="0" height="32" alt="Next Page" width="32"></A></td> <td align="center" width="100%">Python Tutorial</td> <td><A HREF="node2.html"><img src="../icons/contents.gif" border="0" height="32" alt="Contents" width="32"></A></td> <td><img src="../icons/blank.gif" border="0" height="32" alt="" width="32"></td> <td><img src="../icons/blank.gif" border="0" height="32" alt="" width="32"></td> </tr></table> <b class="navlabel">Up:</b> <a class="sectref" HREF="../index.html">Python Documentation Index</A> <b class="navlabel">Next:</b> <a class="sectref" HREF="node1.html">Front Matter</A> <hr> <span class="release-info">Release 2.2, documentation updated on December 21, 2001.</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>