Commits

Yarko Tymciurak  committed 6d4e9f2

adding rendered PDF

  • Participants
  • Parent commits 924380d

Comments (0)

Files changed (51)

File Python3PatternsIdioms.pdf

Binary file added.

File html/CanonicalScript.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/Comprehensions.html

 <p>They require a mind shift.</p>
 <p>What makes them so compelling (once you &#8216;get it&#8217;)?</p>
 <p>A two-level list comprehension using <tt class="docutils literal"><span class="pre">os.walk()</span></tt>:</p>
-<div class="highlight"><pre><span class="c"># Comprehensions/os_walk_comprehension.py</span>
-<span class="kn">import</span> <span class="nn">os</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># Comprehensions/os_walk_comprehension.py</span>
+<span class="k">import</span> <span class="nn">os</span>
 <span class="n">restFiles</span> <span class="o">=</span> <span class="p">[</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="mf">0</span><span class="p">],</span> <span class="n">f</span><span class="p">)</span> <span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">walk</span><span class="p">(</span><span class="s">&quot;.&quot;</span><span class="p">)</span>
              <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">d</span><span class="p">[</span><span class="mf">2</span><span class="p">]</span> <span class="k">if</span> <span class="n">f</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s">&quot;.rst&quot;</span><span class="p">)]</span>
 <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">restFiles</span><span class="p">:</span>
     <span class="k">print</span><span class="p">(</span><span class="n">r</span><span class="p">)</span>
 </pre></div>
 </div>
+</div>
 
 
           </div>
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/Contributors.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/CoroutinesAndConcurrency.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/DeveloperGuide.html

 <blockquote>
 <tt class="docutils literal"><span class="pre">build</span> <span class="pre">help</span></tt></blockquote>
 <p>to see the options.</p>
+<div class="admonition-todo admonition " id="todo-3">
+<p class="first admonition-title">Todo</p>
+<p class="last">Rewrite this section for BitBucket &amp; Mercurial; make some project specific diagrams;</p>
+</div>
 </div>
 <div class="section" id="working-with-launchpad-and-bazaar">
 <h2>Working with Launchpad and Bazaar<a class="headerlink" href="#working-with-launchpad-and-bazaar" title="Permalink to this headline">¶</a></h2>
-<p>(Adapted from a posting by Yarko T)</p>
+<p>(Adapted from a posting by Yarko Tymciurak)</p>
 <p>This assumes that you have created a local branch on your private machine where
 you do work, and keep it merged with the trunk.</p>
 <p>That is, you&#8217;ve done:</p>
 <p>When you are ready to share your work have others review, register a branch.</p>
 <div class="admonition note">
 <p class="first admonition-title">Note</p>
-<p class="last">Once you create a branch, there is no easy way to remove it.</p>
-</div>
-<div class="admonition note">
-<p class="first admonition-title">Note</p>
 <p class="last">You can re-use one branch for multiple bug fixes.</p>
 </div>
 <ol class="arabic simple">
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/GeneratorsIterators.html

             
   
   <div class="section" id="generators-iterators-and-itertools">
-<span id="index-3"></span><h1>Generators, Iterators, and Itertools<a class="headerlink" href="#generators-iterators-and-itertools" title="Permalink to this headline">¶</a></h1>
+<span id="index-4"></span><h1>Generators, Iterators, and Itertools<a class="headerlink" href="#generators-iterators-and-itertools" title="Permalink to this headline">¶</a></h1>
 </div>
 
 
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/Introduction.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/LanguageChanges.html

             
   
   <div class="section" id="python-3-language-changes">
-<span id="index-4"></span><h1>Python 3 Language Changes<a class="headerlink" href="#python-3-language-changes" title="Permalink to this headline">¶</a></h1>
+<span id="index-5"></span><h1>Python 3 Language Changes<a class="headerlink" href="#python-3-language-changes" title="Permalink to this headline">¶</a></h1>
 <p>Covers language features that don&#8217;t require their own chapters.</p>
 <div class="admonition note">
 <p class="first admonition-title">Note</p>
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/MachineDiscovery.html

 but it falls short. Here&#8217;s a rather messy, but useful way to figure out
 everything else.</p>
 <p>Just a starting point:</p>
-<div class="highlight"><pre><span class="k">def</span> <span class="nf">detectCPUs</span><span class="p">():</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">detectCPUs</span><span class="p">():</span>
     <span class="sd">&quot;&quot;&quot;</span>
 <span class="sd">    Detects the number of CPUs on a system. Cribbed from pp.</span>
 <span class="sd">    &quot;&quot;&quot;</span>
     <span class="k">return</span> <span class="mf">1</span> <span class="c"># Default</span>
 </pre></div>
 </div>
+</div>
 
 
           </div>
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/NoteToReaders.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/Part1.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/Part2.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/Part3.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/PythonDecorators.html

             
   
   <div class="section" id="decorators">
-<span id="index-5"></span><h1>Decorators<a class="headerlink" href="#decorators" title="Permalink to this headline">¶</a></h1>
+<span id="index-6"></span><h1>Decorators<a class="headerlink" href="#decorators" title="Permalink to this headline">¶</a></h1>
 <div class="admonition note">
 <p class="first admonition-title">Note</p>
 <p class="last">This chapter is a work in progress; it&#8217;s probably better if you don&#8217;t
 suppose you&#8217;d like to do something at the entry and exit points of a function
 (such as perform some kind of security, tracing, locking, etc. &#8211; all the
 standard arguments for AOP). With decorators, it looks like this:</p>
-<div class="highlight"><pre><span class="nd">@entryExit</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="nd">@entryExit</span>
 <span class="k">def</span> <span class="nf">func1</span><span class="p">():</span>
     <span class="k">print</span><span class="p">(</span><span class="s">&quot;inside func1()&quot;</span><span class="p">)</span>
 
 <span class="k">def</span> <span class="nf">func2</span><span class="p">():</span>
     <span class="k">print</span><span class="p">(</span><span class="s">&quot;inside func2()&quot;</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>The <tt class="docutils literal"><span class="pre">&#64;</span></tt> indicates the application of the decorator.</p>
 </div>
 <div class="section" id="function-decorators">
 <h2>Function Decorators<a class="headerlink" href="#function-decorators" title="Permalink to this headline">¶</a></h2>
 <p>A function decorator is applied to a function definition by placing it on the
 line before that function definition begins. For example:</p>
-<div class="highlight"><pre><span class="nd">@myDecorator</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="nd">@myDecorator</span>
 <span class="k">def</span> <span class="nf">aFunction</span><span class="p">():</span>
     <span class="k">print</span><span class="p">(</span><span class="s">&quot;inside aFunction&quot;</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>When the compiler passes over this code, <tt class="docutils literal"><span class="pre">aFunction()</span></tt> is compiled and the
 resulting function object is passed to the <tt class="docutils literal"><span class="pre">myDecorator</span></tt> code, which does
 something to produce a function-like object that is then substituted for the
 <p>What should the decorator do? Well, it can do anything but usually you expect
 the original function code to be used at some point. This is not required,
 however:</p>
-<div class="highlight"><pre><span class="k">class</span> <span class="nc">myDecorator</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">myDecorator</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
 
     <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
         <span class="k">print</span><span class="p">(</span><span class="s">&quot;inside myDecorator.__init__()&quot;</span><span class="p">)</span>
 
 <span class="n">aFunction</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>When you run this code, you see:</p>
-<pre>inside myDecorator.__init__()
+<div class="highlight-python"><pre>inside myDecorator.__init__()
 inside aFunction()
 Finished decorating aFunction()
 inside myDecorator.__call__()</pre>
+</div>
 <p>Notice that the constructor for <tt class="docutils literal"><span class="pre">myDecorator</span></tt> is executed at the point of
 decoration of the function. Since we can call <tt class="docutils literal"><span class="pre">f()</span></tt> inside <tt class="docutils literal"><span class="pre">__init__()</span></tt>, it
 shows that the creation of <tt class="docutils literal"><span class="pre">f()</span></tt> is complete before the decorator is called.
 function object with the result of the decoration &#8211; in our case, the
 <tt class="docutils literal"><span class="pre">myDecorator</span></tt> object replaces <tt class="docutils literal"><span class="pre">aFunction</span></tt>. Indeed, before decorators were
 added you had to do something much less elegant to achieve the same thing:</p>
-<div class="highlight"><pre><span class="k">def</span> <span class="nf">foo</span><span class="p">():</span> <span class="k">pass</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">foo</span><span class="p">():</span> <span class="k">pass</span>
 <span class="n">foo</span> <span class="o">=</span> <span class="nb">staticmethod</span><span class="p">(</span><span class="n">foo</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>With the addition of the <tt class="docutils literal"><span class="pre">&#64;</span></tt> decoration operator, you now get the same result
 by saying:</p>
-<div class="highlight"><pre><span class="nd">@staticmethod</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="nd">@staticmethod</span>
 <span class="k">def</span> <span class="nf">foo</span><span class="p">():</span> <span class="k">pass</span>
 </pre></div>
+</div>
 <p>This is the reason why people argued against decorators, because the <tt class="docutils literal"><span class="pre">&#64;</span></tt> is
 just a little syntax sugar meaning &#8220;pass a function object through another
 function and assign the result to the original function.&#8221;</p>
 <h2>Slightly More Useful<a class="headerlink" href="#slightly-more-useful" title="Permalink to this headline">¶</a></h2>
 <p>Now let&#8217;s go back and implement the first example. Here, we&#8217;ll do the more
 typical thing and actually use the code in the decorated functions:</p>
-<div class="highlight"><pre><span class="k">class</span> <span class="nc">entryExit</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">entryExit</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
 
     <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
         <span class="bp">self</span><span class="o">.</span><span class="n">f</span> <span class="o">=</span> <span class="n">f</span>
 <span class="n">func1</span><span class="p">()</span>
 <span class="n">func2</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>The output is:</p>
-<pre>Entering func1
+<div class="highlight-python"><pre>Entering func1
 inside func1()
 Exited func1
 Entering func2
 inside func2()
 Exited func2</pre>
+</div>
 <p>You can see that the decorated functions now have the &#8220;Entering&#8221; and &#8220;Exited&#8221;
 trace statements around the call.</p>
 <p>The constructor stores the argument, which is the function object. In the call,
 replaced the original function with an object of a class that has a
 <tt class="docutils literal"><span class="pre">__call__()</span></tt> method. But a function object is also callable, so we can rewrite
 the previous example using a function instead of a class, like this:</p>
-<div class="highlight"><pre><span class="k">def</span> <span class="nf">entryExit</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">entryExit</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
     <span class="k">def</span> <span class="nf">new_f</span><span class="p">():</span>
         <span class="k">print</span><span class="p">(</span><span class="s">&quot;Entering&quot;</span><span class="p">,</span> <span class="n">f</span><span class="o">.</span><span class="n">__name__</span><span class="p">)</span>
         <span class="n">f</span><span class="p">()</span>
 <span class="n">func2</span><span class="p">()</span>
 <span class="k">print</span><span class="p">(</span><span class="n">func1</span><span class="o">.</span><span class="n">__name__</span><span class="p">)</span>
 </pre></div>
+</div>
 <p><tt class="docutils literal"><span class="pre">new_f()</span></tt> is defined within the body of <tt class="docutils literal"><span class="pre">entryExit()</span></tt>, so it is created and
 returned when <tt class="docutils literal"><span class="pre">entryExit()</span></tt> is called. Note that <tt class="docutils literal"><span class="pre">new_f()</span></tt> is a <em>closure</em>,
 because it captures the actual value of <tt class="docutils literal"><span class="pre">f</span></tt>.</p>
 <tt class="docutils literal"><span class="pre">new_f</span></tt> function has been substituted for the original function during
 decoration. If this is a problem you can change the name of the decorator
 function before you return it:</p>
-<div class="highlight"><pre><span class="k">def</span> <span class="nf">entryExit</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">entryExit</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
     <span class="k">def</span> <span class="nf">new_f</span><span class="p">():</span>
         <span class="k">print</span><span class="p">(</span><span class="s">&quot;Entering&quot;</span><span class="p">,</span> <span class="n">f</span><span class="o">.</span><span class="n">__name__</span><span class="p">)</span>
         <span class="n">f</span><span class="p">()</span>
     <span class="n">new_f</span><span class="o">.</span><span class="n">__name__</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">__name__</span>
     <span class="k">return</span> <span class="n">new_f</span>
 </pre></div>
+</div>
 <p>The information you can dynamically get about functions, and the modifications
 you can make to those functions, are quite powerful in Python.</p>
 </div>
 <p>If we create a decorator without arguments, the function to be decorated is
 passed to the constructor, and the <tt class="docutils literal"><span class="pre">__call__()</span></tt> method is called whenever the
 decorated function is invoked:</p>
-<div class="highlight"><pre><span class="k">class</span> <span class="nc">decoratorWithoutArguments</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">decoratorWithoutArguments</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
 
     <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">f</span><span class="p">):</span>
         <span class="sd">&quot;&quot;&quot;</span>
 <span class="n">sayHello</span><span class="p">(</span><span class="s">&quot;a&quot;</span><span class="p">,</span> <span class="s">&quot;different&quot;</span><span class="p">,</span> <span class="s">&quot;set of&quot;</span><span class="p">,</span> <span class="s">&quot;arguments&quot;</span><span class="p">)</span>
 <span class="k">print</span><span class="p">(</span><span class="s">&quot;After second sayHello() call&quot;</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>Any arguments for the decorated function are just passed to <tt class="docutils literal"><span class="pre">__call__()</span></tt>. The
 output is:</p>
-<pre>Inside __init__()
+<div class="highlight-python"><pre>Inside __init__()
 After decoration
 Preparing to call sayHello()
 Inside __call__()
 sayHello arguments: a different set of arguments
 After self.f(*args)
 After second sayHello() call</pre>
+</div>
 <p>Notice that <tt class="docutils literal"><span class="pre">__init__()</span></tt> is the only method called to perform decoration, and
 <tt class="docutils literal"><span class="pre">__call__()</span></tt> is called every time you call the decorated <tt class="docutils literal"><span class="pre">sayHello()</span></tt>.</p>
 </div>
 decorator.</p>
 <p>Let&#8217;s modify the above example to see what happens when we add arguments to the
 decorator:</p>
-<div class="highlight"><pre><span class="k">class</span> <span class="nc">decoratorWithArguments</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">decoratorWithArguments</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
 
     <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">arg1</span><span class="p">,</span> <span class="n">arg2</span><span class="p">,</span> <span class="n">arg3</span><span class="p">):</span>
         <span class="sd">&quot;&quot;&quot;</span>
 <span class="n">sayHello</span><span class="p">(</span><span class="s">&quot;a&quot;</span><span class="p">,</span> <span class="s">&quot;different&quot;</span><span class="p">,</span> <span class="s">&quot;set of&quot;</span><span class="p">,</span> <span class="s">&quot;arguments&quot;</span><span class="p">)</span>
 <span class="k">print</span><span class="p">(</span><span class="s">&quot;after second sayHello() call&quot;</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>From the output, we can see that the behavior changes quite significantly:</p>
-<pre>Inside __init__()
+<div class="highlight-python"><pre>Inside __init__()
 Inside __call__()
 After decoration
 Preparing to call sayHello()
 sayHello arguments: a different set of arguments
 After f(*args)
 after second sayHello() call</pre>
+</div>
 <p>Now the process of decoration calls the constructor and then immediately invokes
 <tt class="docutils literal"><span class="pre">__call__()</span></tt>, which can only take a single argument (the function object) and
 must return the decorated function object that replaces the original. Notice
 <h2>Decorator Functions with Decorator Arguments<a class="headerlink" href="#decorator-functions-with-decorator-arguments" title="Permalink to this headline">¶</a></h2>
 <p>Finally, let&#8217;s look at the more complex decorator function implementation, where
 you have to do everything all at once:</p>
-<div class="highlight"><pre><span class="k">def</span> <span class="nf">decoratorFunctionWithArguments</span><span class="p">(</span><span class="n">arg1</span><span class="p">,</span> <span class="n">arg2</span><span class="p">,</span> <span class="n">arg3</span><span class="p">):</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">decoratorFunctionWithArguments</span><span class="p">(</span><span class="n">arg1</span><span class="p">,</span> <span class="n">arg2</span><span class="p">,</span> <span class="n">arg3</span><span class="p">):</span>
     <span class="k">def</span> <span class="nf">wrap</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
         <span class="k">print</span><span class="p">(</span><span class="s">&quot;Inside wrap()&quot;</span><span class="p">)</span>
         <span class="k">def</span> <span class="nf">wrapped_f</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">):</span>
 <span class="n">sayHello</span><span class="p">(</span><span class="s">&quot;a&quot;</span><span class="p">,</span> <span class="s">&quot;different&quot;</span><span class="p">,</span> <span class="s">&quot;set of&quot;</span><span class="p">,</span> <span class="s">&quot;arguments&quot;</span><span class="p">)</span>
 <span class="k">print</span><span class="p">(</span><span class="s">&quot;after second sayHello() call&quot;</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>Here&#8217;s the output:</p>
-<pre>Inside wrap()
+<div class="highlight-python"><pre>Inside wrap()
 After decoration
 Preparing to call sayHello()
 Inside wrapped_f()
 sayHello arguments: a different set of arguments
 After f(*args)
 after second sayHello() call</pre>
+</div>
 <p>The return value of the decorator function must be a function used to wrap the
 function to be decorated. That is, Python will take the returned function and
 call it at decoration time, passing the function to be decorated. That&#8217;s why we
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/Rules.html

 emphasizing the design here (which I want to do) and putting less focus on the
 C-ish nature that <em>can</em> be expressed in Python.</li>
 </ul>
-<pre>The above point is still being debated.</pre>
+<div class="highlight-python"><pre>The above point is still being debated.</pre>
+</div>
 <ul class="simple">
 <li>Four space indents.</li>
 <li>We&#8217;re not using chapter numbers because we&#8217;ll be moving chapters around.
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/TeachingSupport.html

     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/_sources/DeveloperGuide.txt

 
 to see the options.
 
+.. todo:: Rewrite this section for BitBucket & Mercurial; make some project specific diagrams;
+
 Working with Launchpad and Bazaar
 ===============================================================================
 
-(Adapted from a posting by Yarko T)
+(Adapted from a posting by Yarko Tymciurak)
 
 This assumes that you have created a local branch on your private machine where
 you do work, and keep it merged with the trunk.
 
 When you are ready to share your work have others review, register a branch.
 
-.. note:: Once you create a branch, there is no easy way to remove it.
 
 .. note:: You can re-use one branch for multiple bug fixes.
 

File html/_sources/index.txt

 
 .. toctree::
 
-   Contributors.rst
-   NoteToReaders.rst
-   Introduction.rst
-   TeachingSupport.rst
-   Rules.rst
-   DeveloperGuide.rst
-   Part1.rst
-   quickPython.rst
-   unitTesting.rst
-   LanguageChanges.rst
-   PythonDecorators.rst
-   GeneratorsIterators.rst
-   Comprehensions.rst
-   CoroutinesAndConcurrency.rst
-   jython.rst
-   Part2.rst
-   MachineDiscovery.rst
-   CanonicalScript.rst
-   Part3.rst
-   patternConcept.rst
-   singleton.rst
-   appFrameworks.rst
-   fronting.rst
-   stateMachine.rst
-   decorator.rst
-   iterators.rst
-   factory.rst
-   functionObjects.rst
-   changeInterface.rst
-   tableDriven.rst
-   observer.rst
-   multipleDispatching.rst
-   visitor.rst
-   patternRefactoring.rst
-   projects.rst
+   Contributors
+   ToDoList
+   NoteToReaders
+   Introduction
+   TeachingSupport
+   Rules
+   DeveloperGuide
+   Part1
+   quickPython
+   unitTesting
+   LanguageChanges
+   PythonDecorators
+   GeneratorsIterators
+   Comprehensions
+   CoroutinesAndConcurrency
+   jython
+   Part2
+   MachineDiscovery
+   CanonicalScript
+   Part3
+   patternConcept
+   singleton
+   appFrameworks
+   fronting
+   stateMachine
+   decorator
+   iterators
+   factory
+   functionObjects
+   changeInterface
+   tableDriven
+   observer
+   multipleDispatching
+   visitor
+   patternRefactoring
+   projects
 
 Indices and tables
 ==================

File html/_static/default.css

     font-weight: bold;
 }
 
+/* Sidebars */
+
+div.sidebar {
+    margin: 0 0 0.5em 1em;
+    border: 1px solid #ddb;
+    padding: 7px 7px 0 7px;
+    background-color: #ffe;
+    width: 40%;
+    float: right;
+}
+
+p.sidebar-title {
+    font-weight: bold;
+}
+
 /* "Topics" */
 
 div.topic {
     background-color: #eee;
     border: 1px solid #ccc;
-    padding: 0 7px 0 7px;
+    padding: 7px 7px 0 7px;
     margin: 10px 0 10px 0;
 }
 
     margin-bottom: 0;
 }
 
-div.admonition p {
+div.admonition p.admonition-title + p {
     display: inline;
 }
 

File html/_static/pygments.css

-.hll { background-color: #ffffcc }
 .c { color: #408090; font-style: italic } /* Comment */
 .err { border: 1px solid #FF0000 } /* Error */
 .k { color: #007020; font-weight: bold } /* Keyword */
 .gt { color: #0040D0 } /* Generic.Traceback */
 .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
 .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
-.kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
 .kp { color: #007020 } /* Keyword.Pseudo */
 .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
 .kt { color: #902000 } /* Keyword.Type */

File html/_static/sphinxdoc.css

     font-weight: bold;
 }
 
+div.sidebar {
+    margin: 0 0 0.5em 1em;
+    border: 1px solid #ddb;
+    padding: 7px 7px 0 7px;
+    background-color: #ffe;
+    width: 40%;
+    float: right;
+}
+
+p.sidebar-title {
+    font-weight: bold;
+}
+
+div.topic {
+    background-color: #f8f8f8;
+    border: 1px solid #ccc;
+    padding: 7px 7px 0 7px;
+    margin: 10px 0 10px 0;
+}
+
+p.topic-title {
+    font-size: 1.1em;
+    font-weight: bold;
+}
+
 h1 {
     margin: 0;
     padding: 0.7em 0 0.3em 0;

File html/appFrameworks.html

 override) in order to do its job, but it is usually called only as part of an
 initialization process (and thus the client programmer isn&#8217;t necessarily able to
 call it directly):</p>
-<div class="highlight"><pre><span class="c"># appFrameworks/TemplateMethod.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># appFrameworks/TemplateMethod.py</span>
 <span class="c"># Simple demonstration of Template Method.</span>
 
 <span class="k">class</span> <span class="nc">ApplicationFramework</span><span class="p">:</span>
 
 <span class="n">MyApp</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>The base-class constructor is responsible for performing the necessary
 initialization and then starting the &#8220;engine&#8221; (the template method) that runs
 the application (in a GUI application, this &#8220;engine&#8221; would be the main event
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/changeInterface.html

 <p>When you&#8217;ve got <em>this</em>, and you need <em>that</em>, <em>Adapter</em> solves the problem. The
 only requirement is to produce a <em>that</em>, and there are a number of ways you can
 accomplish this adaptation:</p>
-<div class="highlight"><pre><span class="c"># changeInterface/Adapter.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># changeInterface/Adapter.py</span>
 <span class="c"># Variations on the Adapter pattern.</span>
 
 <span class="k">class</span> <span class="nc">WhatIHave</span><span class="p">:</span>
 <span class="c"># Approach 4:</span>
 <span class="n">whatIUse</span><span class="o">.</span><span class="n">op</span><span class="p">(</span><span class="n">whatIHave3</span><span class="o">.</span><span class="n">whatIWant</span><span class="p">())</span>
 </pre></div>
+</div>
 <p>I&#8217;m taking liberties with the term &#8220;proxy&#8221; here, because in <em>Design Patterns</em>
 they assert that a proxy must have an identical interface with the object that
 it is a surrogate for. However, if you have the two words together: &#8220;proxy
 adapter,&#8221; it is perhaps more reasonable.</p>
 </div>
-<div class="section" id="fa-ade">
-<h2>Façade<a class="headerlink" href="#fa-ade" title="Permalink to this headline">¶</a></h2>
+<div class="section" id="facade">
+<h2>Façade<a class="headerlink" href="#facade" title="Permalink to this headline">¶</a></h2>
 <p>A general principle that I apply when I&#8217;m casting about trying to mold
 requirements into a first-cut object is &#8220;If something is ugly, hide it inside an
 object.&#8221; This is basically what <em>Façade</em> accomplishes. If you have a rather
 <p>Façade is often implemented as singleton abstract factory. Of course, you can
 easily get this effect by creating a class containing <strong>static</strong> factory
 methods:</p>
-<div class="highlight"><pre><span class="c"># changeInterface/Facade.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># changeInterface/Facade.py</span>
 <span class="k">class</span> <span class="nc">A</span><span class="p">:</span>
     <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span> <span class="k">pass</span>
 <span class="k">class</span> <span class="nc">B</span><span class="p">:</span>
 <span class="n">b</span> <span class="o">=</span> <span class="n">Facade</span><span class="o">.</span><span class="n">makeB</span><span class="p">(</span><span class="mf">1</span><span class="p">);</span>
 <span class="n">c</span> <span class="o">=</span> <span class="n">Facade</span><span class="o">.</span><span class="n">makeC</span><span class="p">(</span><span class="mf">1.0</span><span class="p">);</span>
 </pre></div>
+</div>
 <p>[rewrite this section using research from Larman&#8217;s book]</p>
 <p>Example for Facade (?): my &#8220;nicer&#8221; version of the XML library.</p>
 </div>
             <ul>
 <li><a class="reference external" href="">Changing the Interface</a><ul>
 <li><a class="reference external" href="#adapter">Adapter</a></li>
-<li><a class="reference external" href="#fa-ade">Façade</a></li>
+<li><a class="reference external" href="#facade">Façade</a></li>
 <li><a class="reference external" href="#exercises">Exercises</a></li>
 </ul>
 </li>
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/decorator.html

 <p>The key to using this method is to find the particular combination you want.
 So, once you&#8217;ve found the drink you would like, here is how you would use it, as
 shown in the <strong>CoffeeShop</strong> class in the following code:</p>
-<div class="highlight"><pre><span class="c"># decorator/nodecorators/CoffeeShop.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># decorator/nodecorators/CoffeeShop.py</span>
 <span class="c"># Coffee example with no decorators</span>
 
 <span class="k">class</span> <span class="nc">Espresso</span><span class="p">:</span> <span class="k">pass</span>
 <span class="k">print</span><span class="p">((</span><span class="n">cafeMocha</span><span class="o">.</span><span class="n">getDescription</span><span class="p">()</span>
   <span class="o">+</span> <span class="s">&quot;: $&quot;</span> <span class="o">+</span> <span class="sb">`cafeMocha.getCost()`</span><span class="p">))</span>
 </pre></div>
+</div>
 <p>And here is the corresponding output:</p>
-<pre>Cappucino: $1.0
+<div class="highlight-python"><pre>Cappucino: $1.0
 Cafe Mocha decaf whipped cream: $1.25</pre>
+</div>
 <p>You can see that creating the particular combination you want is easy, since you
 are just creating an instance of a class. However, there are a number of
 problems with this approach. Firstly, the combinations are fixed statically so
 and can of course perform processing before or after the invocation.</p>
 <p>So if we added <strong>getTotalCost()</strong> and <strong>getDescription()</strong> methods to the
 <strong>DrinkComponent</strong> interface, an Espresso looks like this:</p>
-<pre># decorator/alldecorators/EspressoDecorator.py
+<div class="highlight-python"><pre># decorator/alldecorators/EspressoDecorator.py
 
 class Espresso(Decorator):
     cost = 0.75f
     def getDescription(self):
         return self.component.getDescription() +
             description</pre>
+</div>
 <p>You combine the components to create a drink as follows, as shown in the code
 below:</p>
-<pre># decorator/alldecorators/CoffeeShop.py
+<div class="highlight-python"><pre># decorator/alldecorators/CoffeeShop.py
 # Coffee example using decorators
 
 class DrinkComponent:
 
 print(cafeMocha.getDescription().strip() + \)
   ": $" + `cafeMocha.getTotalCost()`</pre>
+</div>
 <p>This approach would certainly provide the most flexibility and the smallest
 menu. You have a small number of components to choose from, but assembling the
 description of the coffee then becomes rather arduous.</p>
 <p>If you want to describe a plain cappuccino, you create it with:</p>
-<div class="highlight"><pre><span class="n">plainCap</span> <span class="o">=</span> <span class="n">Espresso</span><span class="p">(</span><span class="n">FoamedMilk</span><span class="p">(</span><span class="n">Mug</span><span class="p">()))</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">plainCap</span> <span class="o">=</span> <span class="n">Espresso</span><span class="p">(</span><span class="n">FoamedMilk</span><span class="p">(</span><span class="n">Mug</span><span class="p">()))</span>
 </pre></div>
+</div>
 <p>Creating a decaf Cafe Mocha with whipped cream requires an even longer
 description.</p>
 </div>
 are presented with in most coffee shops.</p>
 <img alt="_images/compromiseDecoration.gif" src="_images/compromiseDecoration.gif" />
 <p>Here is how to create a basic selection, as well as a decorated selection:</p>
-<pre># decorator/compromise/CoffeeShop.py
+<div class="highlight-python"><pre># decorator/compromise/CoffeeShop.py
 # Coffee example with a compromise of basic
 # combinations and decorators
 
 cafeMocha = Whipped(Decaf(CafeMocha()))
 print(cafeMocha.getDescription() + ": $" + \)
   `cafeMocha.getTotalCost()`</pre>
+</div>
 <p>You can see that creating a basic selection is quick and easy, which makes sense
 since they will be described regularly.  Describing a decorated drink is more
 work than when using a class per combination, but clearly less work than when
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/factory.html

 <h2>Simple Factory Method<a class="headerlink" href="#simple-factory-method" title="Permalink to this headline">¶</a></h2>
 <p>As an example, let&#8217;s revisit the <strong>Shape</strong> system.</p>
 <p>One approach is to make the factory a <strong>static</strong> method of the base class:</p>
-<div class="highlight"><pre><span class="c"># factory/shapefact1/ShapeFactory1.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># factory/shapefact1/ShapeFactory1.py</span>
 <span class="c"># A simple static factory method.</span>
-<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">generators</span>
-<span class="kn">import</span> <span class="nn">random</span>
+<span class="k">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">generators</span>
+<span class="k">import</span> <span class="nn">random</span>
 
 <span class="k">class</span> <span class="nc">Shape</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
     <span class="c"># Create based on class name:</span>
     <span class="n">shape</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>
     <span class="n">shape</span><span class="o">.</span><span class="n">erase</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>The <strong>factory( )</strong> takes an argument that allows it to determine what type of
 <strong>Shape</strong> to create; it happens to be a <strong>String</strong> in this case but it could be
 any set of data. The <strong>factory( )</strong> is now the only other code in the system
 generator has some kind of internal algorithm that tells it what and how to
 build. It &#8220;generates out of thin air&#8221; rather than being told what to create.</p>
 <p>Now, this may not look consistent with the code you see above:</p>
-<pre>for i in shapeNameGen(7)</pre>
+<div class="highlight-python"><pre>for i in shapeNameGen(7)</pre>
+</div>
 <p>looks like there&#8217;s an initialization taking place. This is where a generator is
 a bit strange - when you call a function that contains a <strong>yield</strong> statement
 (<strong>yield</strong> is a new keyword that determines that a function is a generator),
 <p>Thus, the code that you write is actually a kind of factory, that creates the
 generator objects that do the actual generation. You can use the generator
 explicitly if you want, for example:</p>
-<div class="highlight"><pre><span class="n">gen</span> <span class="o">=</span> <span class="n">shapeNameGen</span><span class="p">(</span><span class="mf">7</span><span class="p">)</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">gen</span> <span class="o">=</span> <span class="n">shapeNameGen</span><span class="p">(</span><span class="mf">7</span><span class="p">)</span>
 <span class="k">print</span><span class="p">(</span><span class="n">gen</span><span class="o">.</span><span class="n">next</span><span class="p">())</span>
 </pre></div>
+</div>
 <p>So <strong>next( )</strong> is the iterator method that&#8217;s actually called to generate the
 next object, and it takes no arguments. <strong>shapeNameGen( )</strong> is the factory, and
 <strong>gen</strong> is the generator.</p>
 the list generated by <strong>__subclasses__( )</strong>. If you need to create a deeper
 hierarchy this way, you must recurse the <strong>__subclasses__( )</strong> list.</p>
 <p>Also note that in <strong>shapeNameGen( )</strong> the statement:</p>
-<div class="highlight"><pre><span class="n">types</span> <span class="o">=</span> <span class="n">Shape</span><span class="o">.</span><span class="n">__subclasses__</span><span class="p">()</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="n">types</span> <span class="o">=</span> <span class="n">Shape</span><span class="o">.</span><span class="n">__subclasses__</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>Is only executed when the generator object is produced; each time the <strong>next(
 )</strong> method of this generator object is called (which, as noted above, may happen
 implicitly), only the code in the <strong>for</strong> loop will be executed, so you don&#8217;t
 <h3>Preventing direct creation<a class="headerlink" href="#preventing-direct-creation" title="Permalink to this headline">¶</a></h3>
 <p>To disallow direct access to the classes, you can nest the classes within the
 factory method, like this:</p>
-<div class="highlight"><pre><span class="c"># factory/shapefact1/NestedShapeFactory.py</span>
-<span class="kn">import</span> <span class="nn">random</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># factory/shapefact1/NestedShapeFactory.py</span>
+<span class="k">import</span> <span class="nn">random</span>
 
 <span class="k">class</span> <span class="nc">Shape</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
     <span class="n">types</span> <span class="o">=</span> <span class="p">[]</span>
 </pre></div>
 </div>
 </div>
+</div>
 <div class="section" id="polymorphic-factories">
 <h2>Polymorphic Factories<a class="headerlink" href="#polymorphic-factories" title="Permalink to this headline">¶</a></h2>
 <p>The static <strong>factory( )</strong> method in the previous example forces all the creation
 example of this in the next section). Here is <strong>ShapeFactory1.py</strong> modified so
 the factory methods are in a separate class as virtual functions. Notice also
 that the specific <strong>Shape</strong> classes are dynamically loaded on demand:</p>
-<div class="highlight"><pre><span class="c"># factory/shapefact2/ShapeFactory2.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># factory/shapefact2/ShapeFactory2.py</span>
 <span class="c"># Polymorphic factory methods.</span>
-<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">generators</span>
-<span class="kn">import</span> <span class="nn">random</span>
+<span class="k">from</span> <span class="nn">__future__</span> <span class="k">import</span> <span class="n">generators</span>
+<span class="k">import</span> <span class="nn">random</span>
 
 <span class="k">class</span> <span class="nc">ShapeFactory</span><span class="p">:</span>
     <span class="n">factories</span> <span class="o">=</span> <span class="p">{}</span>
     <span class="n">shape</span><span class="o">.</span><span class="n">draw</span><span class="p">()</span>
     <span class="n">shape</span><span class="o">.</span><span class="n">erase</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>Now the factory method appears in its own class, <strong>ShapeFactory</strong>, as the
 <strong>create( )</strong> method. The different types of shapes must each create their own
 factory with a <strong>create( )</strong> method to create an object of their own type. The
 <p>As another example suppose you are creating a general-purpose gaming environment
 and you want to be able to support different types of games. Here&#8217;s how it might
 look using an abstract factory:</p>
-<div class="highlight"><pre><span class="c"># factory/Games.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># factory/Games.py</span>
 <span class="c"># An example of the Abstract Factory pattern.</span>
 
 <span class="k">class</span> <span class="nc">Obstacle</span><span class="p">:</span>
 <span class="n">g1</span><span class="o">.</span><span class="n">play</span><span class="p">()</span>
 <span class="n">g2</span><span class="o">.</span><span class="n">play</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>In this environment, <strong>Character</strong> objects interact with <strong>Obstacle</strong> objects,
 but there are different types of Characters and obstacles depending on what kind
 of game you&#8217;re playing. You determine the kind of game by choosing a particular
 example) is unnecessary - it&#8217;s only required for languages that have static type
 checking. As long as the concrete Python classes follow the form of the required
 classes, we don&#8217;t need any base classes:</p>
-<div class="highlight"><pre><span class="c"># factory/Games2.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># factory/Games2.py</span>
 <span class="c"># Simplified Abstract Factory.</span>
 
 <span class="k">class</span> <span class="nc">Kitty</span><span class="p">:</span>
 <span class="n">g1</span><span class="o">.</span><span class="n">play</span><span class="p">()</span>
 <span class="n">g2</span><span class="o">.</span><span class="n">play</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>Another way to put this is that all inheritance in Python is implementation
 inheritance; since Python does its type-checking at runtime, there&#8217;s no need to
 use interface inheritance so that you can upcast to the base type.</p>
 <p>You might want to study the two examples for comparison, however. Does the first
 one add enough useful information about the pattern that it&#8217;s worth keeping some
 aspect of it? Perhaps all you need is &#8220;tagging classes&#8221; like this:</p>
-<div class="highlight"><pre><span class="k">class</span> <span class="nc">Obstacle</span><span class="p">:</span> <span class="k">pass</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Obstacle</span><span class="p">:</span> <span class="k">pass</span>
 <span class="k">class</span> <span class="nc">Character</span><span class="p">:</span> <span class="k">pass</span>
 <span class="k">class</span> <span class="nc">GameElementFactory</span><span class="p">:</span> <span class="k">pass</span>
 </pre></div>
+</div>
 <p>Then the inheritance serves only to indicate the type of the derived classes.</p>
 </div>
 <div class="section" id="exercises">
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/fronting.html

 <div class="section" id="proxy">
 <h2>Proxy<a class="headerlink" href="#proxy" title="Permalink to this headline">¶</a></h2>
 <p>If we implement <em>Proxy</em> by following the above diagram, it looks like this:</p>
-<div class="highlight"><pre><span class="c"># fronting/ProxyDemo.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># fronting/ProxyDemo.py</span>
 <span class="c"># Simple demonstration of the Proxy pattern.</span>
 
 <span class="k">class</span> <span class="nc">Implementation</span><span class="p">:</span>
 <span class="n">p</span> <span class="o">=</span> <span class="n">Proxy</span><span class="p">()</span>
 <span class="n">p</span><span class="o">.</span><span class="n">f</span><span class="p">();</span> <span class="n">p</span><span class="o">.</span><span class="n">g</span><span class="p">();</span> <span class="n">p</span><span class="o">.</span><span class="n">h</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>It isn&#8217;t necessary that <strong>Implementation</strong> have the same interface as <strong>Proxy</strong>;
 as long as <strong>Proxy</strong> is somehow &#8220;speaking for&#8221; the class that it is referring
 method calls to then the basic idea is satisfied (note that this statement is at
 that <strong>Proxy</strong> needs to call.</p>
 <p>Of course, in Python we have a delegation mechanism built in, so it makes the
 <strong>Proxy</strong> even simpler to implement:</p>
-<div class="highlight"><pre><span class="c"># fronting/ProxyDemo2.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># fronting/ProxyDemo2.py</span>
 <span class="c"># Simple demonstration of the Proxy pattern.</span>
 
 <span class="k">class</span> <span class="nc">Implementation2</span><span class="p">:</span>
 <span class="n">p</span> <span class="o">=</span> <span class="n">Proxy2</span><span class="p">()</span>
 <span class="n">p</span><span class="o">.</span><span class="n">f</span><span class="p">();</span> <span class="n">p</span><span class="o">.</span><span class="n">g</span><span class="p">();</span> <span class="n">p</span><span class="o">.</span><span class="n">h</span><span class="p">();</span>
 </pre></div>
+</div>
 <p>The beauty of using <strong>__getattr__( )</strong> is that <strong>Proxy2</strong> is completely generic,
 and not tied to any particular implementation (in Java, a rather complicated
 &#8220;dynamic proxy&#8221; has been invented to accomplish this same thing).</p>
 <h2>State<a class="headerlink" href="#state" title="Permalink to this headline">¶</a></h2>
 <p>The <em>State</em> pattern adds more implementations to <em>Proxy</em>, along with a way to
 switch from one implementation to another during the lifetime of the surrogate:</p>
-<div class="highlight"><pre><span class="c"># fronting/StateDemo.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># fronting/StateDemo.py</span>
 <span class="c"># Simple demonstration of the State pattern.</span>
 
 <span class="k">class</span> <span class="nc">State_d</span><span class="p">:</span>
 <span class="n">b</span><span class="o">.</span><span class="n">changeImp</span><span class="p">(</span><span class="n">Implementation2</span><span class="p">())</span>
 <span class="n">run</span><span class="p">(</span><span class="n">b</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>You can see that the first implementation is used for a bit, then the second
 implementation is swapped in and that is used.</p>
 <p>The difference between <em>Proxy</em> and <em>State</em> is in the problems that are solved.
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/functionObjects.html

 wrapping a method in an object, you can pass it to other methods or objects as a
 parameter, to tell them to perform this particular operation in the process of
 fulfilling your request:</p>
-<div class="highlight"><pre><span class="c"># functionObjects/CommandPattern.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># functionObjects/CommandPattern.py</span>
 
 <span class="k">class</span> <span class="nc">Command</span><span class="p">:</span>
     <span class="k">def</span> <span class="nf">execute</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="k">pass</span>
 <span class="n">macro</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">Afford</span><span class="p">())</span>
 <span class="n">macro</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>The primary point of <em>Command</em> is to allow you to hand a desired action to a
 method or object. In the above example, this provides a way to queue a set of
 actions to be performed collectively. In this case, it allows you to dynamically
 <p><em>Strategy</em> also adds a &#8220;Context&#8221; which can be a surrogate class that controls
 the selection and use of the particular strategy object-just like <em>State</em>!
 Here&#8217;s what it looks like:</p>
-<div class="highlight"><pre><span class="c"># functionObjects/StrategyPattern.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># functionObjects/StrategyPattern.py</span>
 
 <span class="c"># The strategy interface:</span>
 <span class="k">class</span> <span class="nc">FindMinima</span><span class="p">:</span>
 <span class="n">solver</span><span class="o">.</span><span class="n">changeAlgorithm</span><span class="p">(</span><span class="n">Bisection</span><span class="p">())</span>
 <span class="k">print</span><span class="p">(</span><span class="n">solver</span><span class="o">.</span><span class="n">minima</span><span class="p">(</span><span class="n">line</span><span class="p">))</span>
 </pre></div>
+</div>
 <p>Note similarity with template method - TM claims distinction that it has more
 than one method to call, does things piecewise. However, it&#8217;s not unlikely that
 strategy object would have more than one method call; consider Shalloway&#8217;s order
 find a solution. <em>Chain of Responsibility</em> provides a way to do this by chaining
 the <em>Strategy</em> objects together and providing a mechanism for them to
 automatically recurse through each one in the chain:</p>
-<div class="highlight"><pre><span class="c"># functionObjects/ChainOfResponsibility.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># functionObjects/ChainOfResponsibility.py</span>
 
 <span class="c"># Carry the information into the strategy:</span>
 <span class="k">class</span> <span class="nc">Messenger</span><span class="p">:</span> <span class="k">pass</span>
 <span class="k">print</span><span class="p">(</span><span class="n">solutions</span><span class="p">[</span><span class="mf">0</span><span class="p">](</span><span class="n">line</span><span class="p">))</span>
 </pre></div>
 </div>
+</div>
 <div class="section" id="exercises">
 <h2>Exercises<a class="headerlink" href="#exercises" title="Permalink to this headline">¶</a></h2>
 <ol class="arabic simple">
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/genindex.html

 <table width="100%" class="indextable"><tr><td width="33%" valign="top">
 <dl>
 
-<dt><a href="PythonDecorators.html#index-5">@: Python decorators</a></dt></dl></td><td width="33%" valign="top"><dl>
+<dt><a href="PythonDecorators.html#index-6">@: Python decorators</a></dt></dl></td><td width="33%" valign="top"><dl>
 </dl></td></tr></table>
 
 <h2 id="C">C</h2>
 <table width="100%" class="indextable"><tr><td width="33%" valign="top">
 <dl>
 
-<dt><a href="PythonDecorators.html#index-5">decorator: Python decorators</a></dt></dl></td><td width="33%" valign="top"><dl>
+<dt><a href="PythonDecorators.html#index-6">decorator: Python decorators</a></dt></dl></td><td width="33%" valign="top"><dl>
 </dl></td></tr></table>
 
 <h2 id="G">G</h2>
   <dd><dl>
     <dt><a href="Comprehensions.html#index-1">comprehension</a></dt>
   </dl></dd>
-<dt><a href="GeneratorsIterators.html#index-3">generators</a></dt></dl></td><td width="33%" valign="top"><dl>
+<dt><a href="GeneratorsIterators.html#index-4">generators</a></dt></dl></td><td width="33%" valign="top"><dl>
 <dt><a href="CoroutinesAndConcurrency.html#index-2">GIL: Global Interpreter Lock</a></dt>
 </dl></td></tr></table>
 
 <table width="100%" class="indextable"><tr><td width="33%" valign="top">
 <dl>
 
-<dt><a href="GeneratorsIterators.html#index-3">iterators</a></dt>
-<dt><a href="GeneratorsIterators.html#index-3">itertools</a></dt></dl></td><td width="33%" valign="top"><dl>
+<dt><a href="GeneratorsIterators.html#index-4">iterators</a></dt>
+<dt><a href="GeneratorsIterators.html#index-4">itertools</a></dt></dl></td><td width="33%" valign="top"><dl>
 </dl></td></tr></table>
 
 <h2 id="L">L</h2>
 
 <dt>Language differences</dt>
   <dd><dl>
-    <dt><a href="LanguageChanges.html#index-4">Python 3</a></dt>
+    <dt><a href="LanguageChanges.html#index-5">Python 3</a></dt>
   </dl></dd>
 <dt>list</dt>
   <dd><dl>
 <dt><a href="CoroutinesAndConcurrency.html#index-2">parallelism</a></dt>
 <dt>Python 3</dt>
   <dd><dl>
-    <dt><a href="LanguageChanges.html#index-4">Language differences</a></dt>
+    <dt><a href="LanguageChanges.html#index-5">Language differences</a></dt>
   </dl></dd></dl></td><td width="33%" valign="top"><dl>
 </dl></td></tr></table>
 
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/index.html

   <div class="section" id="python-3-patterns-idioms">
 <h1>Python 3 Patterns &amp; Idioms<a class="headerlink" href="#python-3-patterns-idioms" title="Permalink to this headline">¶</a></h1>
 <ul>
-<li><a class="reference external" href="Contributors.html">Contributors</a><ul>
-<li><a class="reference external" href="Contributors.html#thanks-to">Thanks To</a></li>
+<li class="toctree-l1"><a class="reference external" href="Contributors.html">Contributors</a><ul>
+<li class="toctree-l2"><a class="reference external" href="Contributors.html#thanks-to">Thanks To</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="NoteToReaders.html">A Note To Readers</a></li>
+<li class="toctree-l1"><a class="reference external" href="NoteToReaders.html">A Note To Readers</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="Introduction.html">Introduction</a><ul>
-<li><a class="reference external" href="Introduction.html#a-team-effort">A Team Effort</a></li>
-<li><a class="reference external" href="Introduction.html#not-an-introductory-book">Not an Introductory Book</a></li>
-<li><a class="reference external" href="Introduction.html#the-license">The License</a></li>
-<li><a class="reference external" href="Introduction.html#the-printed-book">The Printed Book</a></li>
-<li><a class="reference external" href="Introduction.html#translations">Translations</a></li>
-<li><a class="reference external" href="Introduction.html#my-motives">My Motives</a></li>
+<li class="toctree-l1"><a class="reference external" href="Introduction.html">Introduction</a><ul>
+<li class="toctree-l2"><a class="reference external" href="Introduction.html#a-team-effort">A Team Effort</a></li>
+<li class="toctree-l2"><a class="reference external" href="Introduction.html#not-an-introductory-book">Not an Introductory Book</a></li>
+<li class="toctree-l2"><a class="reference external" href="Introduction.html#the-license">The License</a></li>
+<li class="toctree-l2"><a class="reference external" href="Introduction.html#the-printed-book">The Printed Book</a></li>
+<li class="toctree-l2"><a class="reference external" href="Introduction.html#translations">Translations</a></li>
+<li class="toctree-l2"><a class="reference external" href="Introduction.html#my-motives">My Motives</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="TeachingSupport.html">Teaching Support</a></li>
+<li class="toctree-l1"><a class="reference external" href="TeachingSupport.html">Teaching Support</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="Rules.html">Book Development Rules</a><ul>
-<li><a class="reference external" href="Rules.html#contribute-what-you-can">Contribute What You Can</a></li>
-<li><a class="reference external" href="Rules.html#don-t-get-attached">Don&#8217;t Get Attached</a></li>
-<li><a class="reference external" href="Rules.html#credit">Credit</a></li>
-<li><a class="reference external" href="Rules.html#mechanics">Mechanics</a></li>
-<li><a class="reference external" href="Rules.html#diagrams">Diagrams</a></li>
+<li class="toctree-l1"><a class="reference external" href="Rules.html">Book Development Rules</a><ul>
+<li class="toctree-l2"><a class="reference external" href="Rules.html#contribute-what-you-can">Contribute What You Can</a></li>
+<li class="toctree-l2"><a class="reference external" href="Rules.html#don-t-get-attached">Don&#8217;t Get Attached</a></li>
+<li class="toctree-l2"><a class="reference external" href="Rules.html#credit">Credit</a></li>
+<li class="toctree-l2"><a class="reference external" href="Rules.html#mechanics">Mechanics</a></li>
+<li class="toctree-l2"><a class="reference external" href="Rules.html#diagrams">Diagrams</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="DeveloperGuide.html">Developer Guide</a><ul>
-<li><a class="reference external" href="DeveloperGuide.html#for-windows-users">For Windows Users</a></li>
-<li><a class="reference external" href="DeveloperGuide.html#installing-sphinx">Installing Sphinx</a></li>
-<li><a class="reference external" href="DeveloperGuide.html#getting-the-development-branch-of-the-book">Getting the Development Branch of the Book</a></li>
-<li><a class="reference external" href="DeveloperGuide.html#building-the-book">Building the Book</a></li>
-<li><a class="reference external" href="DeveloperGuide.html#working-with-launchpad-and-bazaar">Working with Launchpad and Bazaar</a></li>
-<li><a class="reference external" href="DeveloperGuide.html#branch-registration-details">Branch Registration Details</a></li>
-<li><a class="reference external" href="DeveloperGuide.html#tips-for-merging">Tips for Merging</a></li>
+<li class="toctree-l1"><a class="reference external" href="DeveloperGuide.html">Developer Guide</a><ul>
+<li class="toctree-l2"><a class="reference external" href="DeveloperGuide.html#for-windows-users">For Windows Users</a></li>
+<li class="toctree-l2"><a class="reference external" href="DeveloperGuide.html#installing-sphinx">Installing Sphinx</a></li>
+<li class="toctree-l2"><a class="reference external" href="DeveloperGuide.html#getting-the-development-branch-of-the-book">Getting the Development Branch of the Book</a></li>
+<li class="toctree-l2"><a class="reference external" href="DeveloperGuide.html#building-the-book">Building the Book</a></li>
+<li class="toctree-l2"><a class="reference external" href="DeveloperGuide.html#working-with-launchpad-and-bazaar">Working with Launchpad and Bazaar</a></li>
+<li class="toctree-l2"><a class="reference external" href="DeveloperGuide.html#branch-registration-details">Branch Registration Details</a></li>
+<li class="toctree-l2"><a class="reference external" href="DeveloperGuide.html#tips-for-merging">Tips for Merging</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="Part1.html">Part I: Foundations</a></li>
+<li class="toctree-l1"><a class="reference external" href="Part1.html">Part I: Foundations</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="quickPython.html">Quick Python for Programmers</a><ul>
-<li><a class="reference external" href="quickPython.html#scripting-vs-programming">Scripting vs. Programming</a></li>
-<li><a class="reference external" href="quickPython.html#built-in-containers">Built-In Containers</a></li>
-<li><a class="reference external" href="quickPython.html#functions">Functions</a></li>
-<li><a class="reference external" href="quickPython.html#strings">Strings</a></li>
-<li><a class="reference external" href="quickPython.html#classes">Classes</a><ul>
-<li><a class="reference external" href="quickPython.html#inheritance">Inheritance</a></li>
+<li class="toctree-l1"><a class="reference external" href="quickPython.html">Quick Python for Programmers</a><ul>
+<li class="toctree-l2"><a class="reference external" href="quickPython.html#scripting-vs-programming">Scripting vs. Programming</a></li>
+<li class="toctree-l2"><a class="reference external" href="quickPython.html#built-in-containers">Built-In Containers</a></li>
+<li class="toctree-l2"><a class="reference external" href="quickPython.html#functions">Functions</a></li>
+<li class="toctree-l2"><a class="reference external" href="quickPython.html#strings">Strings</a></li>
+<li class="toctree-l2"><a class="reference external" href="quickPython.html#classes">Classes</a><ul>
+<li class="toctree-l3"><a class="reference external" href="quickPython.html#inheritance">Inheritance</a></li>
 </ul>
 </li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="unitTesting.html">Unit Testing &amp; Test-Driven Development</a><ul>
-<li><a class="reference external" href="unitTesting.html#write-tests-first">Write Tests First</a></li>
-<li><a class="reference external" href="unitTesting.html#simple-python-testing">Simple Python Testing</a></li>
-<li><a class="reference external" href="unitTesting.html#a-very-simple-framework">A Very Simple Framework</a></li>
-<li><a class="reference external" href="unitTesting.html#writing-tests">Writing Tests</a></li>
-<li><a class="reference external" href="unitTesting.html#white-box-black-box-tests">White-Box &amp; Black-Box Tests</a></li>
-<li><a class="reference external" href="unitTesting.html#running-tests">Running tests</a></li>
-<li><a class="reference external" href="unitTesting.html#automatically-executing-tests">Automatically Executing Tests</a></li>
-<li><a class="reference external" href="unitTesting.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="unitTesting.html">Unit Testing &amp; Test-Driven Development</a><ul>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#write-tests-first">Write Tests First</a></li>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#simple-python-testing">Simple Python Testing</a></li>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#a-very-simple-framework">A Very Simple Framework</a></li>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#writing-tests">Writing Tests</a></li>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#white-box-black-box-tests">White-Box &amp; Black-Box Tests</a></li>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#running-tests">Running tests</a></li>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#automatically-executing-tests">Automatically Executing Tests</a></li>
+<li class="toctree-l2"><a class="reference external" href="unitTesting.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="LanguageChanges.html">Python 3 Language Changes</a></li>
+<li class="toctree-l1"><a class="reference external" href="LanguageChanges.html">Python 3 Language Changes</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="PythonDecorators.html">Decorators</a><ul>
-<li><a class="reference external" href="PythonDecorators.html#decorators-vs-the-decorator-pattern">Decorators vs. the Decorator Pattern</a></li>
-<li><a class="reference external" href="PythonDecorators.html#history-of-macros">History of Macros</a></li>
-<li><a class="reference external" href="PythonDecorators.html#the-goal-of-macros">The Goal of Macros</a></li>
-<li><a class="reference external" href="PythonDecorators.html#what-can-you-do-with-decorators">What Can You Do With Decorators?</a></li>
-<li><a class="reference external" href="PythonDecorators.html#function-decorators">Function Decorators</a></li>
-<li><a class="reference external" href="PythonDecorators.html#slightly-more-useful">Slightly More Useful</a></li>
-<li><a class="reference external" href="PythonDecorators.html#using-functions-as-decorators">Using Functions as Decorators</a></li>
-<li><a class="reference external" href="PythonDecorators.html#review-decorators-without-arguments">Review: Decorators without Arguments</a></li>
-<li><a class="reference external" href="PythonDecorators.html#decorators-with-arguments">Decorators with Arguments</a></li>
-<li><a class="reference external" href="PythonDecorators.html#decorator-functions-with-decorator-arguments">Decorator Functions with Decorator Arguments</a></li>
+<li class="toctree-l1"><a class="reference external" href="PythonDecorators.html">Decorators</a><ul>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#decorators-vs-the-decorator-pattern">Decorators vs. the Decorator Pattern</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#history-of-macros">History of Macros</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#the-goal-of-macros">The Goal of Macros</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#what-can-you-do-with-decorators">What Can You Do With Decorators?</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#function-decorators">Function Decorators</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#slightly-more-useful">Slightly More Useful</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#using-functions-as-decorators">Using Functions as Decorators</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#review-decorators-without-arguments">Review: Decorators without Arguments</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#decorators-with-arguments">Decorators with Arguments</a></li>
+<li class="toctree-l2"><a class="reference external" href="PythonDecorators.html#decorator-functions-with-decorator-arguments">Decorator Functions with Decorator Arguments</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="GeneratorsIterators.html">Generators, Iterators, and Itertools</a></li>
+<li class="toctree-l1"><a class="reference external" href="GeneratorsIterators.html">Generators, Iterators, and Itertools</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="Comprehensions.html">Comprehensions</a></li>
+<li class="toctree-l1"><a class="reference external" href="Comprehensions.html">Comprehensions</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="CoroutinesAndConcurrency.html">Coroutines &amp; Concurrency</a></li>
+<li class="toctree-l1"><a class="reference external" href="CoroutinesAndConcurrency.html">Coroutines &amp; Concurrency</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="jython.html">Jython</a><ul>
-<li><a class="reference external" href="jython.html#interpreter-motivation">Interpreter Motivation</a></li>
-<li><a class="reference external" href="jython.html#creating-a-language">Creating a Language</a></li>
-<li><a class="reference external" href="jython.html#controlling-the-interpreter">Controlling the Interpreter</a><ul>
-<li><a class="reference external" href="jython.html#putting-data-in">Putting Data In</a></li>
-<li><a class="reference external" href="jython.html#getting-data-out">Getting Data Out</a></li>
-<li><a class="reference external" href="jython.html#multiple-interpreters">Multiple Interpreters</a></li>
+<li class="toctree-l1"><a class="reference external" href="jython.html">Jython</a><ul>
+<li class="toctree-l2"><a class="reference external" href="jython.html#interpreter-motivation">Interpreter Motivation</a></li>
+<li class="toctree-l2"><a class="reference external" href="jython.html#creating-a-language">Creating a Language</a></li>
+<li class="toctree-l2"><a class="reference external" href="jython.html#controlling-the-interpreter">Controlling the Interpreter</a><ul>
+<li class="toctree-l3"><a class="reference external" href="jython.html#putting-data-in">Putting Data In</a></li>
+<li class="toctree-l3"><a class="reference external" href="jython.html#getting-data-out">Getting Data Out</a></li>
+<li class="toctree-l3"><a class="reference external" href="jython.html#multiple-interpreters">Multiple Interpreters</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="jython.html#controlling-java-from-jython">Controlling Java from Jython</a><ul>
-<li><a class="reference external" href="jython.html#inner-classes">Inner Classes</a></li>
+<li class="toctree-l2"><a class="reference external" href="jython.html#controlling-java-from-jython">Controlling Java from Jython</a><ul>
+<li class="toctree-l3"><a class="reference external" href="jython.html#inner-classes">Inner Classes</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="jython.html#using-java-libraries">Using Java libraries</a><ul>
-<li><a class="reference external" href="jython.html#inheriting-from-java-library-classes">Inheriting from Java library Classes</a></li>
+<li class="toctree-l2"><a class="reference external" href="jython.html#using-java-libraries">Using Java libraries</a><ul>
+<li class="toctree-l3"><a class="reference external" href="jython.html#inheriting-from-java-library-classes">Inheriting from Java library Classes</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="jython.html#creating-java-classes-with-jython">Creating Java classes with Jython</a><ul>
-<li><a class="reference external" href="jython.html#building-java-classes-from-python">Building Java Classes from Python</a></li>
+<li class="toctree-l2"><a class="reference external" href="jython.html#creating-java-classes-with-jython">Creating Java classes with Jython</a><ul>
+<li class="toctree-l3"><a class="reference external" href="jython.html#building-java-classes-from-python">Building Java Classes from Python</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="jython.html#summary">Summary</a></li>
-<li><a class="reference external" href="jython.html#exercises">Exercises</a></li>
+<li class="toctree-l2"><a class="reference external" href="jython.html#summary">Summary</a></li>
+<li class="toctree-l2"><a class="reference external" href="jython.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="Part2.html">Part II: Idioms</a></li>
+<li class="toctree-l1"><a class="reference external" href="Part2.html">Part II: Idioms</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="MachineDiscovery.html">Discovering the Details About Your Platform</a></li>
+<li class="toctree-l1"><a class="reference external" href="MachineDiscovery.html">Discovering the Details About Your Platform</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="CanonicalScript.html">A Canonical Form for Command-Line Programs</a></li>
+<li class="toctree-l1"><a class="reference external" href="CanonicalScript.html">A Canonical Form for Command-Line Programs</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="Part3.html">Part III: Patterns</a></li>
+<li class="toctree-l1"><a class="reference external" href="Part3.html">Part III: Patterns</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="patternConcept.html">The Pattern Concept</a><ul>
-<li><a class="reference external" href="patternConcept.html#what-is-a-pattern">What is a Pattern?</a></li>
-<li><a class="reference external" href="patternConcept.html#classifying-patterns">Classifying Patterns</a></li>
-<li><a class="reference external" href="patternConcept.html#pattern-taxonomy">Pattern Taxonomy</a></li>
-<li><a class="reference external" href="patternConcept.html#design-structures">Design Structures</a></li>
-<li><a class="reference external" href="patternConcept.html#design-principles">Design Principles</a></li>
+<li class="toctree-l1"><a class="reference external" href="patternConcept.html">The Pattern Concept</a><ul>
+<li class="toctree-l2"><a class="reference external" href="patternConcept.html#what-is-a-pattern">What is a Pattern?</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternConcept.html#classifying-patterns">Classifying Patterns</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternConcept.html#pattern-taxonomy">Pattern Taxonomy</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternConcept.html#design-structures">Design Structures</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternConcept.html#design-principles">Design Principles</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="singleton.html">The Singleton</a><ul>
-<li><a class="reference external" href="singleton.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="singleton.html">The Singleton</a><ul>
+<li class="toctree-l2"><a class="reference external" href="singleton.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="appFrameworks.html">Building Application Frameworks</a><ul>
-<li><a class="reference external" href="appFrameworks.html#template-method">Template Method</a></li>
-<li><a class="reference external" href="appFrameworks.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="appFrameworks.html">Building Application Frameworks</a><ul>
+<li class="toctree-l2"><a class="reference external" href="appFrameworks.html#template-method">Template Method</a></li>
+<li class="toctree-l2"><a class="reference external" href="appFrameworks.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="fronting.html">Fronting for an Implementation</a><ul>
-<li><a class="reference external" href="fronting.html#proxy">Proxy</a></li>
-<li><a class="reference external" href="fronting.html#state">State</a></li>
+<li class="toctree-l1"><a class="reference external" href="fronting.html">Fronting for an Implementation</a><ul>
+<li class="toctree-l2"><a class="reference external" href="fronting.html#proxy">Proxy</a></li>
+<li class="toctree-l2"><a class="reference external" href="fronting.html#state">State</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="stateMachine.html">StateMachine</a><ul>
-<li><a class="reference external" href="stateMachine.html#table-driven-state-machine">Table-Driven State Machine</a><ul>
-<li><a class="reference external" href="stateMachine.html#the-state-class">The State Class</a></li>
-<li><a class="reference external" href="stateMachine.html#conditions-for-transition">Conditions for Transition</a></li>
-<li><a class="reference external" href="stateMachine.html#transition-actions">Transition Actions</a></li>
-<li><a class="reference external" href="stateMachine.html#the-table">The Table</a></li>
-<li><a class="reference external" href="stateMachine.html#the-basic-machine">The Basic Machine</a></li>
-<li><a class="reference external" href="stateMachine.html#simple-vending-machine">Simple Vending Machine</a></li>
-<li><a class="reference external" href="stateMachine.html#testing-the-machine">Testing the Machine</a></li>
+<li class="toctree-l1"><a class="reference external" href="stateMachine.html">StateMachine</a><ul>
+<li class="toctree-l2"><a class="reference external" href="stateMachine.html#table-driven-state-machine">Table-Driven State Machine</a><ul>
+<li class="toctree-l3"><a class="reference external" href="stateMachine.html#the-state-class">The State Class</a></li>
+<li class="toctree-l3"><a class="reference external" href="stateMachine.html#conditions-for-transition">Conditions for Transition</a></li>
+<li class="toctree-l3"><a class="reference external" href="stateMachine.html#transition-actions">Transition Actions</a></li>
+<li class="toctree-l3"><a class="reference external" href="stateMachine.html#the-table">The Table</a></li>
+<li class="toctree-l3"><a class="reference external" href="stateMachine.html#the-basic-machine">The Basic Machine</a></li>
+<li class="toctree-l3"><a class="reference external" href="stateMachine.html#simple-vending-machine">Simple Vending Machine</a></li>
+<li class="toctree-l3"><a class="reference external" href="stateMachine.html#testing-the-machine">Testing the Machine</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="stateMachine.html#tools">Tools</a></li>
-<li><a class="reference external" href="stateMachine.html#exercises">Exercises</a></li>
+<li class="toctree-l2"><a class="reference external" href="stateMachine.html#tools">Tools</a></li>
+<li class="toctree-l2"><a class="reference external" href="stateMachine.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="decorator.html">Decorator: Dynamic Type Selection</a><ul>
-<li><a class="reference external" href="decorator.html#basic-decorator-structure">Basic Decorator Structure</a></li>
-<li><a class="reference external" href="decorator.html#a-coffee-example">A Coffee Example</a></li>
-<li><a class="reference external" href="decorator.html#class-for-each-combination">Class for Each Combination</a></li>
-<li><a class="reference external" href="decorator.html#the-decorator-approach">The Decorator Approach</a></li>
-<li><a class="reference external" href="decorator.html#compromise">Compromise</a></li>
-<li><a class="reference external" href="decorator.html#other-considerations">Other Considerations</a></li>
-<li><a class="reference external" href="decorator.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="decorator.html">Decorator: Dynamic Type Selection</a><ul>
+<li class="toctree-l2"><a class="reference external" href="decorator.html#basic-decorator-structure">Basic Decorator Structure</a></li>
+<li class="toctree-l2"><a class="reference external" href="decorator.html#a-coffee-example">A Coffee Example</a></li>
+<li class="toctree-l2"><a class="reference external" href="decorator.html#class-for-each-combination">Class for Each Combination</a></li>
+<li class="toctree-l2"><a class="reference external" href="decorator.html#the-decorator-approach">The Decorator Approach</a></li>
+<li class="toctree-l2"><a class="reference external" href="decorator.html#compromise">Compromise</a></li>
+<li class="toctree-l2"><a class="reference external" href="decorator.html#other-considerations">Other Considerations</a></li>
+<li class="toctree-l2"><a class="reference external" href="decorator.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="iterators.html">Iterators: Decoupling Algorithms from Containers</a><ul>
-<li><a class="reference external" href="iterators.html#type-safe-iterators">Type-Safe Iterators</a></li>
+<li class="toctree-l1"><a class="reference external" href="iterators.html">Iterators: Decoupling Algorithms from Containers</a><ul>
+<li class="toctree-l2"><a class="reference external" href="iterators.html#type-safe-iterators">Type-Safe Iterators</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="factory.html">Factory: Encapsulating Object Creation</a><ul>
-<li><a class="reference external" href="factory.html#simple-factory-method">Simple Factory Method</a><ul>
-<li><a class="reference external" href="factory.html#preventing-direct-creation">Preventing direct creation</a></li>
+<li class="toctree-l1"><a class="reference external" href="factory.html">Factory: Encapsulating Object Creation</a><ul>
+<li class="toctree-l2"><a class="reference external" href="factory.html#simple-factory-method">Simple Factory Method</a><ul>
+<li class="toctree-l3"><a class="reference external" href="factory.html#preventing-direct-creation">Preventing direct creation</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="factory.html#polymorphic-factories">Polymorphic Factories</a></li>
-<li><a class="reference external" href="factory.html#abstract-factories">Abstract Factories</a></li>
-<li><a class="reference external" href="factory.html#exercises">Exercises</a></li>
+<li class="toctree-l2"><a class="reference external" href="factory.html#polymorphic-factories">Polymorphic Factories</a></li>
+<li class="toctree-l2"><a class="reference external" href="factory.html#abstract-factories">Abstract Factories</a></li>
+<li class="toctree-l2"><a class="reference external" href="factory.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="functionObjects.html">Function Objects</a><ul>
-<li><a class="reference external" href="functionObjects.html#command-choosing-the-operation-at-runtime">Command: Choosing the Operation at Runtime</a></li>
-<li><a class="reference external" href="functionObjects.html#strategy-choosing-the-algorithm-at-runtime">Strategy: Choosing the Algorithm at Runtime</a></li>
-<li><a class="reference external" href="functionObjects.html#chain-of-responsibility">Chain of Responsibility</a></li>
-<li><a class="reference external" href="functionObjects.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="functionObjects.html">Function Objects</a><ul>
+<li class="toctree-l2"><a class="reference external" href="functionObjects.html#command-choosing-the-operation-at-runtime">Command: Choosing the Operation at Runtime</a></li>
+<li class="toctree-l2"><a class="reference external" href="functionObjects.html#strategy-choosing-the-algorithm-at-runtime">Strategy: Choosing the Algorithm at Runtime</a></li>
+<li class="toctree-l2"><a class="reference external" href="functionObjects.html#chain-of-responsibility">Chain of Responsibility</a></li>
+<li class="toctree-l2"><a class="reference external" href="functionObjects.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="changeInterface.html">Changing the Interface</a><ul>
-<li><a class="reference external" href="changeInterface.html#adapter">Adapter</a></li>
-<li><a class="reference external" href="changeInterface.html#fa-ade">Façade</a></li>
-<li><a class="reference external" href="changeInterface.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="changeInterface.html">Changing the Interface</a><ul>
+<li class="toctree-l2"><a class="reference external" href="changeInterface.html#adapter">Adapter</a></li>
+<li class="toctree-l2"><a class="reference external" href="changeInterface.html#facade">Façade</a></li>
+<li class="toctree-l2"><a class="reference external" href="changeInterface.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="tableDriven.html">Table-Driven Code: Configuration Flexibility</a><ul>
-<li><a class="reference external" href="tableDriven.html#table-driven-code-using-anonymous-inner-classes">Table-Driven Code Using Anonymous Inner Classes</a></li>
+<li class="toctree-l1"><a class="reference external" href="tableDriven.html">Table-Driven Code: Configuration Flexibility</a><ul>
+<li class="toctree-l2"><a class="reference external" href="tableDriven.html#table-driven-code-using-anonymous-inner-classes">Table-Driven Code Using Anonymous Inner Classes</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="observer.html">Observer</a><ul>
-<li><a class="reference external" href="observer.html#observing-flowers">Observing Flowers</a><ul>
-<li><a class="reference external" href="observer.html#a-visual-example-of-observers">A Visual Example of Observers</a></li>
-<li><a class="reference external" href="observer.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="observer.html">Observer</a><ul>
+<li class="toctree-l2"><a class="reference external" href="observer.html#observing-flowers">Observing Flowers</a><ul>
+<li class="toctree-l3"><a class="reference external" href="observer.html#a-visual-example-of-observers">A Visual Example of Observers</a></li>
+<li class="toctree-l3"><a class="reference external" href="observer.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="multipleDispatching.html">Multiple Dispatching</a></li>
+<li class="toctree-l1"><a class="reference external" href="multipleDispatching.html">Multiple Dispatching</a></li>
 </ul>
 <ul>
-<li><a class="reference external" href="visitor.html">Visitor</a><ul>
-<li><a class="reference external" href="visitor.html#exercises">Exercises</a></li>
+<li class="toctree-l1"><a class="reference external" href="visitor.html">Visitor</a><ul>
+<li class="toctree-l2"><a class="reference external" href="visitor.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="patternRefactoring.html">Pattern Refactoring</a><ul>
-<li><a class="reference external" href="patternRefactoring.html#simulating-the-trash-recycler">Simulating the Trash Recycler</a></li>
-<li><a class="reference external" href="patternRefactoring.html#improving-the-design">Improving the Design</a><ul>
-<li><a class="reference external" href="patternRefactoring.html#make-more-objects">&#8220;Make More Objects&#8221;</a></li>
+<li class="toctree-l1"><a class="reference external" href="patternRefactoring.html">Pattern Refactoring</a><ul>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#simulating-the-trash-recycler">Simulating the Trash Recycler</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#improving-the-design">Improving the Design</a><ul>
+<li class="toctree-l3"><a class="reference external" href="patternRefactoring.html#make-more-objects">&#8220;Make More Objects&#8221;</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="patternRefactoring.html#a-pattern-for-prototyping-creation">A Pattern for Prototyping Creation</a><ul>
-<li><a class="reference external" href="patternRefactoring.html#trash-subclasses"><strong>Trash</strong> Subclasses</a></li>
-<li><a class="reference external" href="patternRefactoring.html#parsing-trash-from-an-external-file">Parsing <strong>Trash</strong> from an External File</a></li>
-<li><a class="reference external" href="patternRefactoring.html#recycling-with-prototyping">Recycling with Prototyping</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#a-pattern-for-prototyping-creation">A Pattern for Prototyping Creation</a><ul>
+<li class="toctree-l3"><a class="reference external" href="patternRefactoring.html#trash-subclasses"><strong>Trash</strong> Subclasses</a></li>
+<li class="toctree-l3"><a class="reference external" href="patternRefactoring.html#parsing-trash-from-an-external-file">Parsing <strong>Trash</strong> from an External File</a></li>
+<li class="toctree-l3"><a class="reference external" href="patternRefactoring.html#recycling-with-prototyping">Recycling with Prototyping</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="patternRefactoring.html#abstracting-usage">Abstracting Usage</a></li>
-<li><a class="reference external" href="patternRefactoring.html#multiple-dispatching">Multiple Dispatching</a><ul>
-<li><a class="reference external" href="patternRefactoring.html#implementing-the-double-dispatch">Implementing the Double Dispatch</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#abstracting-usage">Abstracting Usage</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#multiple-dispatching">Multiple Dispatching</a><ul>
+<li class="toctree-l3"><a class="reference external" href="patternRefactoring.html#implementing-the-double-dispatch">Implementing the Double Dispatch</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="patternRefactoring.html#the-visitor-pattern">The <em>Visitor</em> Pattern</a><ul>
-<li><a class="reference external" href="patternRefactoring.html#a-reflective-decorator">A Reflective Decorator</a></li>
-<li><a class="reference external" href="patternRefactoring.html#more-coupling">More Coupling?</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#the-visitor-pattern">The <em>Visitor</em> Pattern</a><ul>
+<li class="toctree-l3"><a class="reference external" href="patternRefactoring.html#a-reflective-decorator">A Reflective Decorator</a></li>
+<li class="toctree-l3"><a class="reference external" href="patternRefactoring.html#more-coupling">More Coupling?</a></li>
 </ul>
 </li>
-<li><a class="reference external" href="patternRefactoring.html#rtti-considered-harmful">RTTI Considered Harmful?</a></li>
-<li><a class="reference external" href="patternRefactoring.html#summary">Summary</a></li>
-<li><a class="reference external" href="patternRefactoring.html#exercises">Exercises</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#rtti-considered-harmful">RTTI Considered Harmful?</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#summary">Summary</a></li>
+<li class="toctree-l2"><a class="reference external" href="patternRefactoring.html#exercises">Exercises</a></li>
 </ul>
 </li>
 </ul>
 <ul>
-<li><a class="reference external" href="projects.html">Projects</a><ul>
-<li><a class="reference external" href="projects.html#rats-mazes">Rats &amp; Mazes</a><ul>
-<li><a class="reference external" href="projects.html#other-maze-resources">Other Maze Resources</a></li>
+<li class="toctree-l1"><a class="reference external" href="projects.html">Projects</a><ul>
+<li class="toctree-l2"><a class="reference external" href="projects.html#rats-mazes">Rats &amp; Mazes</a><ul>
+<li class="toctree-l3"><a class="reference external" href="projects.html#other-maze-resources">Other Maze Resources</a></li>
 </ul>
 </li>
 </ul>
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/iterators.html

 can be used in the same places (you may argue that this is actually a <em>Proxy</em>
 pattern, but it&#8217;s more likely <em>Decorator</em> because of its intent). Here is the
 code:</p>
-<pre># util/TypedIterator.py
+<div class="highlight-python"><pre># util/TypedIterator.py
 
 class TypedIterator(Iterator):
     def __init__(self, it, type):
         return obj</pre>
 </div>
 </div>
+</div>
 
 
           </div>
     </div>
     <div class="footer">
       &copy; Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
-      Last updated on Nov 09, 2008.
+      Last updated on Nov 10, 2008.
       Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.5.
     </div>
   </body>

File html/jython.html

 The constructor initializes these fields, and then adds the new <strong>Event</strong> object
 to a static list called <strong>events</strong> (defining it in the class, but outside of any
 methods, is what makes it static):</p>
-<div class="highlight"><pre><span class="c"># jython/GreenHouseLanguage.py</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># jython/GreenHouseLanguage.py</span>
 
 <span class="k">class</span> <span class="nc">Event</span><span class="p">:</span>
     <span class="n">events</span> <span class="o">=</span> <span class="p">[]</span> <span class="c"># static</span>
     <span class="n">Bell</span><span class="p">(</span><span class="mf">7.00</span><span class="p">)</span>
     <span class="n">run</span><span class="p">()</span>
 </pre></div>
+</div>
 <p>The constructor of each derived class calls the base-class constructor, which
 adds the new object to the list. The <strong>run( )</strong> function sorts the list, which
 automatically uses the <strong>__cmp__( )</strong> method that was defined in <strong>Event</strong> to
 let&#8217;s use Jython, inside of Java. This turns out to be remarkably simple: you
 import some Jython classes, create a <strong>PythonInterpreter</strong> object, and cause the
 Python files to be loaded:</p>
-<div class="highlight"><pre><span class="c">// jython/GreenHouseController.java</span>
-<span class="kn">package</span> <span class="n">jython</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">org.python.util.PythonInterpreter</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">org.python.core.*</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">junit.framework.*</span><span class="o">;</span>
+<div class="highlight-java"><div class="highlight"><pre><span class="c">// jython/GreenHouseController.java</span>
+<span class="k">package</span> <span class="n">jython</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">org.python.util.PythonInterpreter</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">org.python.core.*</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">junit.framework.*</span><span class="o">;</span>
 
-<span class="kd">public</span> <span class="kd">class</span>
-<span class="nc">GreenHouseController</span> <span class="kd">extends</span> <span class="n">TestCase</span>  <span class="o">{</span>
+<span class="k">public</span> <span class="k">class</span>
+<span class="nc">GreenHouseController</span> <span class="k">extends</span> <span class="n">TestCase</span>  <span class="o">{</span>
   <span class="n">PythonInterpreter</span> <span class="n">interp</span> <span class="o">=</span>
     <span class="k">new</span> <span class="nf">PythonInterpreter</span><span class="o">();</span>
-  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">test</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">PyException</span>  <span class="o">{</span>
+  <span class="k">public</span> <span class="kt">void</span> <span class="nf">test</span><span class="o">()</span> <span class="k">throws</span> <span class="n">PyException</span>  <span class="o">{</span>
     <span class="n">System</span><span class="o">.</span><span class="na">out</span><span class="o">.</span><span class="na">println</span><span class="o">(</span>
       <span class="s">&quot;Loading GreenHouse Language&quot;</span><span class="o">);</span>
     <span class="n">interp</span><span class="o">.</span><span class="na">execfile</span><span class="o">(</span><span class="s">&quot;GreenHouseLanguage.py&quot;</span><span class="o">);</span>
       <span class="s">&quot;Executing GreenHouse Script&quot;</span><span class="o">);</span>
     <span class="n">interp</span><span class="o">.</span><span class="na">exec</span><span class="o">(</span><span class="s">&quot;run()&quot;</span><span class="o">);</span>
   <span class="o">}</span>
-  <span class="kd">public</span> <span class="kd">static</span> <span class="kt">void</span>
-  <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="kd">throws</span> <span class="n">PyException</span>  <span class="o">{</span>
+  <span class="k">public</span> <span class="k">static</span> <span class="kt">void</span>
+  <span class="nf">main</span><span class="o">(</span><span class="n">String</span><span class="o">[]</span> <span class="n">args</span><span class="o">)</span> <span class="k">throws</span> <span class="n">PyException</span>  <span class="o">{</span>
     <span class="n">junit</span><span class="o">.</span><span class="na">textui</span><span class="o">.</span><span class="na">TestRunner</span><span class="o">.</span><span class="na">run</span><span class="o">(</span><span class="n">GreenHouseController</span><span class="o">.</span><span class="na">class</span><span class="o">);</span>
   <span class="o">}</span>
 <span class="o">}</span>
 </pre></div>
+</div>
 <p>The <strong>PythonInterpreter</strong> object is a complete Python interpreter that accepts
 commands from the Java program. One of these commands is <strong>execfile( )</strong>, which
 tells it to execute all the statements it finds in a particular file. By
 into our <strong>PythonInterpreter</strong> object, and so it now &#8220;holds&#8221; the greenhouse
 controller language. The <strong>Schedule.ghs</strong> file is the one created by the end
 user to control the greenhouse. Here&#8217;s an example:</p>
-<div class="highlight"><pre><span class="c"># jython/Schedule.ghs</span>
+<div class="highlight-python"><div class="highlight"><pre><span class="c"># jython/Schedule.ghs</span>
 <span class="n">Bell</span><span class="p">(</span><span class="mf">7.00</span><span class="p">)</span>
 <span class="n">ThermostatDay</span><span class="p">(</span><span class="mf">6.00</span><span class="p">)</span>
 <span class="n">WaterOn</span><span class="p">(</span><span class="mf">3.30</span><span class="p">)</span>
 <span class="n">LightOff</span><span class="p">(</span><span class="mf">2.00</span><span class="p">)</span>
 <span class="n">WaterOff</span><span class="p">(</span><span class="mf">4.45</span><span class="p">)</span>
 </pre></div>
+</div>
 <p>This is the goal of the interpreter design pattern: to make the configuration of
 your program as simple as possible for the end user. With Jython you can achieve
 this with almost no effort at all.</p>
 data types and performs conversions upon them.  The following example is a
 reasonably thorough exercise of the various <strong>set( )</strong> possibilities, along with
 comments that should give a fairly complete explanation:</p>
-<div class="highlight"><pre><span class="c">// jython/PythonInterpreterSetting.java</span>
+<div class="highlight-java"><div class="highlight"><pre><span class="c">// jython/PythonInterpreterSetting.java</span>
 <span class="c">// Passing data from Java to python when using</span>
 <span class="c">// the PythonInterpreter object.</span>
-<span class="kn">package</span> <span class="n">jython</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">org.python.util.PythonInterpreter</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">org.python.core.*</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">java.util.*</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">net.mindview.python.*</span><span class="o">;</span>
-<span class="kn">import</span> <span class="nn">junit.framework.*</span><span class="o">;</span>
+<span class="k">package</span> <span class="n">jython</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">org.python.util.PythonInterpreter</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">org.python.core.*</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">java.util.*</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">net.mindview.python.*</span><span class="o">;</span>
+<span class="k">import</span> <span class="nn">junit.framework.*</span><span class="o">;</span>
 
-<span class="kd">public</span> <span class="kd">class</span>
-<span class="nc">PythonInterpreterSetting</span> <span class="kd">extends</span> <span class="n">TestCase</span>  <span class="o">{</span>
+<span class="k">public</span> <span class="k">class</span>
+<span class="nc">PythonInterpreterSetting</span> <span class="k">extends</span> <span class="n">TestCase</span>  <span class="o">{</span>
   <span class="n">PythonInterpreter</span> <span class="n">interp</span> <span class="o">=</span>
     <span class="k">new</span> <span class="nf">PythonInterpreter</span><span class="o">();</span>
-  <span class="kd">public</span> <span class="kt">void</span> <span class="nf">test</span><span class="o">()</span> <span class="kd">throws</span> <span class="n">PyException</span>  <span class="o">{</span>
+  <span class="k">public</span> <span class="kt">void</span> <span class="nf">test</span><span class="o">()</span> <span class="k">throws</span> <span class="n">PyException</span>  <span class="o">{</span>
     <span class="c">// It automatically converts Strings</span>
     <span class="c">// into native Python strings:</span>