Skip to content

Commit

Permalink
skeleton of advanced iterators chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Pilgrim committed Mar 29, 2009
1 parent 62b8489 commit 3057428
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 45 deletions.
27 changes: 27 additions & 0 deletions advanced-iterators.html
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<head>
<meta charset=utf-8>
<title>Advanced Iterators - Dive into Python 3</title>
<link rel=stylesheet type=text/css href=dip3.css>
<style>
body{counter-reset:h1 6}
</style>
</head>
<form action=http://www.google.com/cse><div><input type=hidden name=cx value=014021643941856155761:l5eihuescdw><input type=hidden name=ie value=UTF-8>&nbsp;<input name=q size=31>&nbsp;<input type=submit name=sa value=Search></div></form>
<p>You are here: <a href=index.html>Home</a> <span>&#8227;</span> <a href=table-of-contents.html#advanced-iterators>Dive Into Python 3</a> <span>&#8227;</span>
<h1>Iterators <i class=baa>&amp;</i> Generators</h1>
<blockquote class=q>
<p><span>&#x275D;</span> FIXME <span>&#x275E;</span><br>&mdash; FIXME
</blockquote>
<p id=toc>&nbsp;
<h2 id=divingin>Diving In</h2>
<p class=f>FIXME

<h2 id=furtherreading>Further Reading</h2>
<ul>
</ul>

<p class=c>&copy; 2001&ndash;9 <a href=about.html><span>&#x2133;</span>ark Pilgrim</a>
<script src=jquery.js></script>
<script src=dip3.js></script>

4 changes: 2 additions & 2 deletions index.html
Expand Up @@ -27,13 +27,13 @@ <h1>Dive Into Python 3</h1>
<li><a href=native-datatypes.html>Native Datatypes</a>
<li><a href=strings.html>Strings</a>
<li><a href=regular-expressions.html>Regular Expressions</a>
<li class=todo>The power of introspection
<li><a href=iterators-and-generators.html>Iterators <i class=baa>&amp;</i> Generators</a>
<li><a href=advanced-iterators.html>Advanced Iterators</a>
<li class=todo>Objects and object-orientation
<li><a href=unit-testing.html>Unit Testing</a>
<li class=todo>Test-first programming
<li class=todo>Refactoring your code
<li class=todo>Files
<li><a href=iterators-and-generators.html>Iterators <i class=baa>&amp;</i> Generators</a>
<li class=todo>HTML processing
<li class=todo>XML processing
<li class=todo>Web services
Expand Down
8 changes: 4 additions & 4 deletions iterators-and-generators.html
Expand Up @@ -4,7 +4,7 @@
<title>Iterators &amp; generators - Dive into Python 3</title>
<link rel=stylesheet type=text/css href=dip3.css>
<style>
body{counter-reset:h1 11}
body{counter-reset:h1 5}
</style>
</head>
<form action=http://www.google.com/cse><div><input type=hidden name=cx value=014021643941856155761:l5eihuescdw><input type=hidden name=ie value=UTF-8>&nbsp;<input name=q size=31>&nbsp;<input type=submit name=sa value=Search></div></form>
Expand All @@ -15,9 +15,8 @@ <h1>Iterators <i class=baa>&amp;</i> Generators</h1>
</blockquote>
<p id=toc>&nbsp;
<h2 id=divingin>Diving In</h2>
<p class=f>Let&#8217;s talk about plural nouns. Also, functions that return other functions, advanced regular expressions, iterators, and generators. But first, let&#8217;s talk about how to make plural nouns. (If you haven&#8217;t read <a href=regular-expressions.html>the chapter on regular expressions</a>, now would be a good time. This chapter assumes you understand the basics of regular expressions, and quickly descends into more advanced uses.)
<p>English is a schizophrenic language that borrows from a lot of other languages, and the rules for making singular nouns into plural nouns are varied and complex. There are rules, and then there are exceptions to those rules, and then there are exceptions to the exceptions.
<aside>English is a schizophrenic language.</aside>
<p class=f>English is a schizophrenic language that borrows words from many other languages. The most basic linguistic operations, like taking a singular noun and turning it into a plural noun, are complicated by the language's mixed heritage. There are rules, and then there are exceptions to those rules, and then there are exceptions to the exceptions.
<p>In this chapter, you&#8217;re going to learn about about plural nouns. Also, functions that return other functions, advanced regular expressions, iterators, and generators. But first, let&#8217;s talk about how to make plural nouns. (If you haven&#8217;t read <a href=regular-expressions.html>the chapter on regular expressions</a>, now would be a good time. This chapter assumes you understand the basics of regular expressions, and it quickly descends into more advanced uses.)
<p>If you grew up in an English-speaking country or learned English in a formal school setting, you&#8217;re probably familiar with the basic rules:
<ul>
<li>If a word ends in S, X, or Z, add ES. <i>Bass</i> becomes <i>basses</i>, <i>fax</i> becomes <i>faxes</i>, and <i>waltz</i> becomes <i>waltzes</i>.
Expand Down Expand Up @@ -250,6 +249,7 @@ <h2 id=a-file-of-patterns>A File Of Patterns</h2>

<p>Now let&#8217;s see how you can use this rules file.

<p>[FIXME: now that this chapter comes before the I/O chapter, need to at least mention what open() does]
<p class=d>[<a href=examples/plural4.py>download <code>plural4.py</code></a>]
<pre><code>import re

Expand Down
53 changes: 17 additions & 36 deletions table-of-contents.html
Expand Up @@ -118,28 +118,28 @@ <h1>Table of contents</h1>
<li><a href=regular-expressions.html#phonenumbers>Case study: parsing phone numbers</a>
<li><a href=regular-expressions.html#summary>Summary</a>
</ol>
<li>The power of introspection
<li id=iterators-and-generators><a href=iterators-and-generators.html>Iterators <i class=baa>&amp;</i> generators</a>
<ol>
<li>Diving in
<li>Using optional and named arguments
<ol>
<li>Keyword-only arguments
</ol>
<li>Using type, str, dir, and other built-in functions
<li><a href=iterators-and-generators.html#divingin>Diving in</a>
<li><a href=iterators-and-generators.html#i-know>I know, let&#8217;s use regular expressions!</a>
<li><a href=iterators-and-generators.html#a-list-of-functions>A list of functions</a>
<li><a href=iterators-and-generators.html#a-list-of-patterns>A list of patterns</a>
<li><a href=iterators-and-generators.html#a-file-of-patterns>A file of patterns</a>
<li><a href=iterators-and-generators.html#generators>Generators</a>
<ol>
<li>The type function
<li>The str function
<li>Built-in functions
<li><a href=iterators-and-generators.html#a-fibonacci-generator>A Fibonacci generator</a>
<li><a href=iterators-and-generators.html#a-plural-rule-generator>A plural rule generator</a>
</ol>
<li>Getting object references with getattr
<li><a href=iterators-and-generators.html#iterators>Iterators</a>
<ol>
<li>getattr with modules
<li>getattr as a dispatcher
<li><a href=iterators-and-generators.html#a-fibonacci-iterator>A Fibonacci iterator</a>
<li><a href=iterators-and-generators.html#a-plural-rule-iterator>A plural rule iterator</a>
</ol>
<li>Filtering lists
<li>Using lambda functions
<li>Putting it all together
<li>Summary
<li><a href=iterators-and-generators.html#furtherreading>Further reading</a>
</ol>
<li><a href=advanced-iterators.html>Advanced Iterators</a>
<ol>
<li><a href=advanced-iterators.html#divingin>Diving in</a>
</ol>
<li>Objects and object-orientation
<ol>
Expand Down Expand Up @@ -178,25 +178,6 @@ <h1>Table of contents</h1>
<li>Handling errors (exceptions)
<li>Writing to files
</ol>
<li id=iterators-and-generators><a href=iterators-and-generators.html>Iterators <i class=baa>&amp;</i> generators</a>
<ol>
<li><a href=iterators-and-generators.html#divingin>Diving in</a>
<li><a href=iterators-and-generators.html#i-know>I know, let&#8217;s use regular expressions!</a>
<li><a href=iterators-and-generators.html#a-list-of-functions>A list of functions</a>
<li><a href=iterators-and-generators.html#a-list-of-patterns>A list of patterns</a>
<li><a href=iterators-and-generators.html#a-file-of-patterns>A file of patterns</a>
<li><a href=iterators-and-generators.html#generators>Generators</a>
<ol>
<li><a href=iterators-and-generators.html#a-fibonacci-generator>A Fibonacci generator</a>
<li><a href=iterators-and-generators.html#a-plural-rule-generator>A plural rule generator</a>
</ol>
<li><a href=iterators-and-generators.html#iterators>Iterators</a>
<ol>
<li><a href=iterators-and-generators.html#a-fibonacci-iterator>A Fibonacci iterator</a>
<li><a href=iterators-and-generators.html#a-plural-rule-iterator>A plural rule iterator</a>
</ol>
<li><a href=iterators-and-generators.html#furtherreading>Further reading</a>
</ol>
<li>HTML processing
<ol>
<li>Diving in
Expand Down
5 changes: 2 additions & 3 deletions unit-testing.html
Expand Up @@ -4,7 +4,7 @@
<title>Unit testing - Dive into Python 3</title>
<link rel=stylesheet type=text/css href=dip3.css>
<style>
body{counter-reset:h1 7}
body{counter-reset:h1 8}
</style>
</head>
<form action=http://www.google.com/cse><div><input type=hidden name=cx value=014021643941856155761:l5eihuescdw><input type=hidden name=ie value=UTF-8>&nbsp;<input name=q size=31>&nbsp;<input type=submit name=root value=Search></div></form>
Expand All @@ -15,8 +15,7 @@ <h1>Unit Testing</h1>
</blockquote>
<p id=toc>&nbsp;
<h2 id=divingin>(Not) Diving In</h2>
<p class=f>How do you know that the code you wrote yesterday still works after the changes you made today? Every seasoned programmer has war stories of an &#8220;innocent&#8221; change that couldn't <em>possibly</em> have affected that other &#8220;unrelated&#8221; module&hellip; If this sounds familiar, this chapter is for you.
<p>In this chapter, you're going to write and debug a set of utility functions to convert to and from Roman numerals. You saw the mechanics of constructing and validating Roman numerals in <a href="regular-expressions.html#romannumerals">&#8220;Case study: roman numerals&#8221;</a>. Now step back and consider what it would take to expand that into a two-way utility.
<p class=f>In this chapter, you're going to write and debug a set of utility functions to convert to and from Roman numerals. You saw the mechanics of constructing and validating Roman numerals in <a href="regular-expressions.html#romannumerals">&#8220;Case study: roman numerals&#8221;</a>. Now step back and consider what it would take to expand that into a two-way utility.
<p><a href="regular-expressions.html#romannumerals">The rules for Roman numerals</a> lead to a number of interesting observations:
<ol>
<li>There is only one correct way to represent a particular number as Roman numerals.
Expand Down

0 comments on commit 3057428

Please sign in to comment.