BruceEckel / Python 3 Patterns & Idioms (http://mindviewinc.com/Books/Python3Patterns/Index.php)

An open source book written and edited by Bruce Eckel with contributions and help from the Python community. Published under the Creative Commons Attribution-Share Alike 3.0 license. To download the current version of the HTML book and example code, click the "download" link you'll see in the upper right. This includes the sources for building the book.

commit 47: 162d6c89b09a
parent 46: 4b769ef208b2
branch: default
Another rewrite of Jython.rst, which is now in decent enough shape for the conference.
Bruce Eckel / BruceEckel
21 months ago

Changed (Δ8.8 KB):

raw changeset »

Python3PatternsIdioms.pdf (binary file changed)

code/Jython/Walk_comprehension.py (2 lines added, 1 lines removed)

html/Jython.html (394 lines added, 357 lines removed)

html/ToDo.html (2 lines added, 2 lines removed)

html/_sources/Jython.txt (400 lines added, 364 lines removed)

html/genindex.html (1 lines added, 1 lines removed)

html/index.html (5 lines added, 3 lines removed)

html/search.html (1 lines added, 1 lines removed)

html/searchindex.js (1 lines added, 1 lines removed)

src/Jython.rst (400 lines added, 364 lines removed)

Up to file-list Python3PatternsIdioms.pdf:

Binary file has changed or diff was empty.

Up to file-list code/Jython/Walk_comprehension.py:

1
1
# Jython/Walk_comprehension.py
2
2
import os
3
3
restFiles = [os.path.join(d[0], f) for d in os.walk(".")
4
             for f in d[2] if f.endswith(".java")]
4
             for f in d[2] if f.endswith(".java") and 
5
             "PythonInterpreter" in open(os.path.join(d[0], f)).read()]
5
6
for r in restFiles:
6
7
    print(r)

Up to file-list html/Jython.html:

@@ -58,58 +58,41 @@ and will need changes when Jython 3 come
58
58
that the material can be used to introduce Java programmers to
59
59
Jython.</p>
60
60
</div>
61
<p>This chapter looks at the value of crossing language boundaries. It is often
62
advantageous to solve a problem using more than one programming language, rather
63
than being arbitrarily stuck using a single language. As you’ll see in this
64
chapter, a problem that is very difficult or tedious to solve in one language
65
can often be solved quickly and easily in another. If you can combine the use of
66
languages, you can create your product much more quickly and cheaply.</p>
67
<p>The most straightforward use of this idea is the <em>Interpreter</em> design
68
pattern, which adds an interpreted language to your program to allow
69
the end user to easily customize a solution. If the application user
70
needs greater run time flexibility, for example to create scripts
71
describing the desired behavior of the system, you can use
72
<em>Interpreter</em> by creating and embedding a language interpreter into
73
your program.</p>
61
<p>Sometimes it’s easier and faster to temporarily step into another
62
language to solve a particular aspect of your problem.</p>
63
<p>This chapter looks at the value of crossing language boundaries. It is
64
often advantageous to solve a problem using more than one programming
65
language; as you’ll see, a problem that is very difficult or tedious
66
to solve in one language can often be solved quickly and easily in
67
another. By combining languages, you can create your product much more
68
quickly and cheaply.</p>
69
<p>One use of this idea is the <em>Interpreter</em> design pattern, which adds
70
an interpreted language to your program to allow the end user to
71
easily customize a solution. If the application user needs greater run
72
time flexibility, for example to create scripts describing the desired
73
behavior of the system, you can use <em>Interpreter</em> by creating and
74
embedding a language interpreter into your program.</p>
74
75
<p>In Java, the easiest and most powerful way to do this is with <em>Jython</em>
75
76
<a class="footnote-reference" href="#id3" id="id1">[1]</a>, an implementation of Python in pure Java byte codes. As you will
76
77
see, this brings together the benefits of both worlds.</p>
77
<p><em>Interpreter</em> solves a particular problem – that of creating a
78
scripting language for the user. But sometimes it’s just easier and
79
faster to temporarily step into another language to solve a particular
80
aspect of your problem. You’re not creating an interpreter, you’re
81
just writing some code in another language.</p>
82
<div class="section" id="interpreter-motivation">
83
<h2>Interpreter Motivation<a class="headerlink" href="#interpreter-motivation" title="Permalink to this headline">¶</a></h2>
84
<p>Remember that each design pattern allows one or more factors to change, so it’s
85
important to first be aware of which factor is changing. Sometimes the end users
86
of your application (rather than the programmers of that application) need
87
complete flexibility in the way that they configure some aspect of the program.
88
That is, they need to do some kind of simple programming. The interpreter
89
pattern provides this flexibility by adding a language interpreter.</p>
90
<p>The problem is that developing your own language and building an interpreter is
91
a time-consuming distraction from the process of developing your application.
92
You must ask whether you want to finish writing your application or create a new
93
language.  The best solution is to reuse code: embed an interpreter that’s
94
already been built and debugged for you. The Python language can be freely
95
embedded into your for-profit application without signing any license agreement,
96
paying royalties, or dealing with strings of any kind. There are basically no
97
restrictions at all when you’re using Python.</p>
98
<p>For solving Java problems, we will look at a special version of Python called
99
Jython. This is generated entirely in Java byte codes, so incorporating it into
100
your application is quite simple,  and it’s as portable as Java is. It has an
101
extremely clean interface with Java: Java can call Python classes, and Python
102
can call Java classes.</p>
78
<p>Jython is generated entirely in Java byte codes, so incorporating it
79
into your application is quite simple, and it’s as portable as Java
80
is. It has an extremely clean interface with Java: Java can call
81
Python classes, and Python can call Java classes.</p>
103
82
<p>Because Jython is just Java classes, it can often be “stealthed” into
104
83
companies that have rigid processes for using new languges and
105
84
tools. If Java has been accepted, such companies often accept anything
106
85
that runs on the JVM without question.</p>
107
<p>Python is designed with classes from the ground up and is a truly pure object
108
oriented language (both C++ and Java violate purity in various ways). Python
109
scales up so that you can create very big programs without losing control of the
110
code. Java projects have been quickly created using Jython, then later optimized by
111
rewriting sections of the Jython code that have profiled as bottlenecks into Java.</p>
112
</div>
86
<p>The Python/Jython language can be freely embedded into your for-profit
87
application without signing any license agreement, paying royalties,
88
or dealing with strings of any kind. There are basically no
89
restrictions when you’re using Python/Jython.</p>
90
<p>Python is designed with classes from the ground up and provides pure
91
support for object-oriented programming (both C++ and Java violate
92
purity in various ways). Python scales up so that you can create large
93
programs without losing control of the code. Java projects have been
94
quickly created using Jython, then later optimized by rewriting into
95
Java sections of the Jython code that have profiled as bottlenecks.</p>
113
96
<div class="section" id="installation">
114
97
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this headline">¶</a></h2>
115
98
<p>To install Jython, go to <a class="reference external" href="http://jython.sourceforge.net">http://jython.sourceforge.net</a>.</p>
@@ -157,7 +140,7 @@ See: <a class="reference external" href=
157
140
</div>
158
141
<div class="section" id="scripting">
159
142
<h2>Scripting<a class="headerlink" href="#scripting" title="Permalink to this headline">¶</a></h2>
160
<p>One very compelling benefit of using a dynamic language on the JVM is
143
<p>One compelling benefit of using a dynamic language on the JVM is
161
144
scripting.  You can rapidly create and test code, and solve problems
162
145
more quickly.</p>
163
146
<p>Here’s an example that shows a little of what you can do in a Jython
@@ -191,17 +174,17 @@ that Jython could run faster than cpytho
191
174
benefits of the JVM. The total runtime of the cpython version is
192
175
faster because of its rapid startup time; the JVM always has a delay
193
176
for startup.</p>
194
<p>Note that things that require much more code (and often research) in
195
Java are very quick to write in Jython. Here’s an example that uses
196
a Python <em>list comprehension</em> with the <strong>os.walk()</strong> function to visit
197
all the directories in a directory tree, and find all the files with names
198
that end in <strong>.java</strong> (of course you can easily do more sophisticated things
199
like opening the file and looking for information within it):</p>
177
<p>Note that things that are very quick to write in Jython require much
178
more code (and often research) in Java. Here’s an example that uses a
179
Python <em>list comprehension</em> with the <strong>os.walk()</strong> function to visit
180
all the directories in a directory tree, and find all the files with
181
names that end in <strong>.java</strong> and contain the word <strong>PythonInterpreter</strong>:</p>
200
182
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Jython/Walk_comprehension.py</span>
201
183
<span class="k">import</span> <span class="nn">os</span>
202
184
203
185
<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">"."</span><span class="p">)</span>
204
             <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">".java"</span><span class="p">)]</span>
186
             <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">".java"</span><span class="p">)</span> <span class="ow">and</span>
187
             <span class="s">"PythonInterpreter"</span> <span class="ow">in</span> <span class="nb">open</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="o">.</span><span class="n">read</span><span class="p">()]</span>
205
188
206
189
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">restFiles</span><span class="p">:</span>
207
190
    <span class="k">print</span><span class="p">(</span><span class="n">r</span><span class="p">)</span>
@@ -212,16 +195,31 @@ like opening the file and looking for in
212
195
The fact that you can quickly try things out allows you to test
213
196
concepts, and then create more refined code as needed.</p>
214
197
</div>
198
<div class="section" id="interpreter-motivation">
199
<h2>Interpreter Motivation<a class="headerlink" href="#interpreter-motivation" title="Permalink to this headline">¶</a></h2>
200
<p>Remember that each design pattern allows one or more factors to
201
change, so it’s important to first be aware of which factor is
202
changing. Sometimes the end users of your application (rather than the
203
programmers of that application) need complete flexibility in the way
204
that they configure some aspect of the program.  That is, they need to
205
do some kind of simple programming. The <em>Interpreter</em> pattern provides
206
this flexibility by adding a language interpreter.</p>
207
<p>The problem is that creating your own language and building an
208
interpreter is a time-consuming distraction from the process of
209
developing your application.  You must ask whether you want to finish
210
writing your application or make a new language.  The best solution is
211
to reuse code: embed an interpreter that’s already been built and
212
debugged for you.</p>
215
213
<div class="section" id="creating-a-language">
216
<h2>Creating a Language<a class="headerlink" href="#creating-a-language" title="Permalink to this headline">¶</a></h2>
214
<h3>Creating a Language<a class="headerlink" href="#creating-a-language" title="Permalink to this headline">¶</a></h3>
217
215
<p>It turns out to be remarkably simple to use Jython to create an
218
216
interpreted language inside your application. Consider the greenhouse
219
217
controller example from <em>Thinking in Java</em>. This is a situation where
220
218
you want the end user – the person managing the greenhouse – to have
221
219
configuration control over the system, and so a simple scripting
222
language is the ideal solution.  This is often called a
223
<em>domain-specific language</em> (DSL) because it solves a particular
224
domain problem.</p>
220
language is an ideal solution.  This is often called a
221
<em>domain-specific language</em> (DSL) because it solves a particular domain
222
problem.</p>
225
223
<p>To create the language, we’ll simply write a set of Python classes,
226
224
and the constructor of each will add itself to a (static) master
227
225
list. The common data and behavior will be factored into the base
@@ -301,19 +299,19 @@ but outside of any methods, is what make
301
299
<p class="last">To run this program say <tt class="docutils literal"><span class="pre">python</span> <span class="pre">GreenHouseLanguage.py</span></tt> or
302
300
<tt class="docutils literal"><span class="pre">jython</span> <span class="pre">GreenHouseLanguage.py</span></tt>.</p>
303
301
</div>
304
<p>The constructor of each derived class calls the base-class constructor, which
305
adds the new object to the list. The <strong>run()</strong> function sorts the list, which
306
automatically uses the <strong>__cmp__()</strong> method defined in <strong>Event</strong> to
307
base comparisons on time only. In this example, it only prints out the list, but
308
in the real system it would wait for the time of each event to come up and then
309
run the event.</p>
302
<p>The constructor of each derived class calls the base-class
303
constructor, which adds the new object to the list. The <strong>run()</strong>
304
function sorts the list, which automatically uses the <strong>__cmp__()</strong>
305
method defined in <strong>Event</strong> to base comparisons on time only. In this
306
example, it only prints out the list, but in the real system it would
307
wait for the time of each event to come up and then run the event.</p>
310
308
<p>The <strong>__main__</strong> section performs a simple test on the classes.</p>
311
309
<p>The above file – which is an ordinary Python program – is now a
312
module that can be included in another Python program.
313
But instead of using it in an ordinary Python program,
314
let’s use Jython, inside of Java. This turns out to be remarkably
315
simple: you import some Jython classes, create a <strong>PythonInterpreter</strong>
316
object, and cause the Python files to be loaded:</p>
310
module that can be included in another Python program.  But instead of
311
using it in an ordinary Python program, let’s use Jython, inside of
312
Java. This turns out to be remarkably simple: you import some Jython
313
classes, create a <strong>PythonInterpreter</strong> object, and cause the Python
314
files to be loaded:</p>
317
315
<div class="highlight-java"><div class="highlight"><pre><span class="c">// Jython/GreenHouseController.java</span>
318
316
<span class="k">import</span> <span class="nn">org.python.core.*</span><span class="o">;</span>
319
317
<span class="k">import</span> <span class="nn">org.python.util.PythonInterpreter</span><span class="o">;</span>
@@ -331,13 +329,14 @@ object, and cause the Python files to be
331
329
<span class="o">}</span>
332
330
</pre></div>
333
331
</div>
334
<p>The <strong>PythonInterpreter</strong> object is a complete Python interpreter that accepts
335
commands from the Java program. One of these commands is <strong>execfile()</strong>, which
336
tells it to execute all the statements it finds in a particular file. By
337
executing <strong>GreenHouseLanguage.py</strong>, all the classes from that file are loaded
338
into our <strong>PythonInterpreter</strong> object, and so it now “holds” the greenhouse
339
controller language. The <strong>Schedule.ghs</strong> file is the one created by the end
340
user to control the greenhouse. Here’s an example:</p>
332
<p>The <strong>PythonInterpreter</strong> object is a complete Python interpreter that
333
accepts commands from the Java program. One of these commands is
334
<strong>execfile()</strong>, which tells it to execute all the statements it finds
335
in a particular file. By executing <strong>GreenHouseLanguage.py</strong>, all the
336
classes from that file are loaded into our <strong>PythonInterpreter</strong>
337
object, and so it now “holds” the greenhouse controller language. The
338
<strong>Schedule.ghs</strong> file is the one created by the end user to control
339
the greenhouse. Here’s an example:</p>
341
340
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Jython/Schedule.ghs</span>
342
341
<span class="n">Bell</span><span class="p">(</span><span class="mf">7.00</span><span class="p">)</span>
343
342
<span class="n">ThermostatDay</span><span class="p">(</span><span class="mf">6.00</span><span class="p">)</span>
@@ -348,19 +347,20 @@ user to control the greenhouse. HereR
348
347
<span class="n">WaterOff</span><span class="p">(</span><span class="mf">4.45</span><span class="p">)</span>
349
348
</pre></div>
350
349
</div>
351
<p>This is the goal of the interpreter design pattern: to make the configuration of
352
your program as simple as possible for the end user. With Jython you can achieve
353
this with almost no effort at all.</p>
350
<p>This is the goal of the interpreter design pattern: to make the
351
configuration of your program as simple as possible for the end
352
user. With Jython you can achieve this with almost no effort at all.</p>
354
353
<p>One of the other methods available to the <strong>PythonInterpreter</strong> is
355
354
<strong>exec()</strong>, which allows you to send a command to the interpreter. In
356
355
the above program, the <strong>run()</strong> function is called using <strong>exec()</strong>.</p>
357
356
</div>
357
</div>
358
358
<div class="section" id="using-java-libraries">
359
359
<h2>Using Java libraries<a class="headerlink" href="#using-java-libraries" title="Permalink to this headline">¶</a></h2>
360
<p>Jython wraps the Java libraries so that any of them can be used directly or via
361
inheritance. In addition, Python shorthand simplifies coding.</p>
362
<p>As an example, consider the <strong>HTMLButton.java</strong> example from
363
<em>Thinking in Java</em>. Here is its conversion to Jython:</p>
360
<p>Jython wraps Java libraries so that any of them can be used directly
361
or via inheritance. In addition, Python shorthand simplifies coding.</p>
362
<p>As an example, consider the <strong>HTMLButton.java</strong> example from <em>Thinking
363
in Java</em>. Here is its conversion to Jython:</p>
364
364
<div class="highlight-python"><div class="highlight"><pre><span class="c"># Jython/PythonSwing.py</span>
365
365
<span class="c"># The HTMLButton.java example from "Thinking in Java"</span>
366
366
<span class="c"># converted into Jython.</span>
@@ -387,19 +387,21 @@ inheritance. In addition, Python shortha
387
387
</pre></div>
388
388
</div>
389
389
<p>If you compare the Java version of the program to the above Jython
390
implementation, you’ll see that Jython is shorter and generally easier to
391
understand. For example, to set up the frame in the Java version you had to make
392
several calls: the constructor for <strong>JFrame()</strong>, the <strong>setVisible()</strong> method
393
and the <strong>setDefaultCloseOperation()</strong> method, whereas in the above code all
394
three of these operations are performed with a single constructor call.</p>
395
<p>Also notice that the <strong>JButton</strong> is configured with an <strong>actionListener()</strong>
396
method inside the constructor, with the assignment to <strong>kapow</strong>. In addition,
397
Jython’s JavaBean awareness means that a call to any method with a name that
398
begins with “<strong>set</strong>” can be replaced with an assignment, as you see above.</p>
399
<p>The only method that did not come over from Java is the <strong>pack()</strong> method,
400
which seems to be essential in order to force the layout to happen properly.
401
It’s also important that the call to <strong>pack()</strong> appear <em>before</em> the <strong>size</strong>
402
setting.</p>
390
implementation, you’ll see that Jython is shorter and generally easier
391
to understand. For example, to set up the frame in the Java version
392
you had to make several calls: the constructor for <strong>JFrame()</strong>, the
393
<strong>setVisible()</strong> method and the <strong>setDefaultCloseOperation()</strong> method,
394
whereas in the above code all three of these operations are performed
395
with a single constructor call.</p>
396
<p>Also notice that the <strong>JButton</strong> is configured with an
397
<strong>actionListener()</strong> method inside the constructor, with the
398
assignment to <strong>kapow</strong>. In addition, Jython’s JavaBean awareness
399
means that a call to any method with a name that begins with “<strong>set</strong>”
400
can be replaced with an assignment, as you see above.</p>
401
<p>The only method that did not come over from Java is the <strong>pack()</strong>
402
method, which seems to be essential in order to force the layout to
403
happen properly.  It’s also important that the call to <strong>pack()</strong>
404
appear <em>before</em> the <strong>size</strong> setting.</p>
403
405
<div class="section" id="inheriting-from-java-library-classes">
404
406
<h3>Inheriting from Java library Classes<a class="headerlink" href="#inheriting-from-java-library-classes" title="Permalink to this headline">¶</a></h3>
405
407
<p>You can easily inherit from standard Java library classes in
@@ -430,22 +432,23 @@ converted into Jython:</p>
430
432
<span class="n">frame</span><span class="o">.</span><span class="n">pack</span><span class="p">()</span>
431
433
</pre></div>
432
434
</div>
433
<p><strong>MyDialog</strong> is inherited from <strong>JDialog</strong>, and you can see named arguments
434
being used in the call to the base-class constructor.</p>
435
<p>In the creation of the “OK” <strong>JButton</strong>, note that the <strong>actionPerformed</strong>
436
method is set right inside the constructor, and that the function is created
437
using the Python <strong>lambda</strong> keyword. This creates a nameless function with the
438
arguments appearing before the colon and the expression that generates the
439
returned value after the colon. As you should know, the Java prototype for the
440
<strong>actionPerformed()</strong> method only contains a single argument, but the lambda
441
expression indicates two. However, the second argument is provided with a
442
default value, so the function <em>can</em> be called with only one argument. The
443
reason for the second argument is seen in the default value, because this is a
444
way to pass <strong>self</strong> into the lambda expression, so that it can be used to
445
dispose of the dialog.</p>
446
<p>Compare this code with the version that’s published in <em>Thinking in Java</em>.
447
You’ll find that Python language features allow a much more succinct and direct
448
implementation.</p>
435
<p><strong>MyDialog</strong> is inherited from <strong>JDialog</strong>, and you can see named
436
arguments being used in the call to the base-class constructor.</p>
437
<p>In the creation of the “OK” <strong>JButton</strong>, note that the
438
<strong>actionPerformed</strong> method is set right inside the constructor, and
439
that the function is created using the Python <strong>lambda</strong> keyword. This
440
creates a nameless function with the arguments appearing before the
441
colon and the expression that generates the returned value after the
442
colon. As you should know, the Java prototype for the
443
<strong>actionPerformed()</strong> method only contains a single argument, but the
444
lambda expression indicates two. However, the second argument is
445
provided with a default value, so the function <em>can</em> be called with
446
only one argument. The reason for the second argument is seen in the
447
default value, because this is a way to pass <strong>self</strong> into the lambda
448
expression, so that it can be used to dispose of the dialog.</p>
449
<p>Compare this code with the version that’s published in <em>Thinking in
450
Java</em>.  You’ll find that Python language features allow a much more
451
succinct and direct implementation.</p>
449
452
</div>
450
453
</div>
451
454
<div class="section" id="controlling-java-from-jython">
@@ -507,55 +510,61 @@ create yourself, as you can see here:</p
507
510
<span class="k">print</span><span class="p">(</span><span class="n">jc</span><span class="o">.</span><span class="n">val</span><span class="p">)</span>
508
511
</pre></div>
509
512
</div>
510
<div class="admonition-todo admonition " id="todo-20">
513
<div class="admonition-todo admonition " id="todo-25">
511
514
<p class="first admonition-title">Todo</p>
512
515
<p class="last">rewrite to distinguish python generator from above description, or
513
516
choose different name.</p>
514
517
</div>
515
<p>Note that the <strong>import</strong> statements map to the Java package structure exactly as
516
you would expect. In the first example, a <strong>Date()</strong> object is created as if it
517
were a native Python class, and printing this object just calls <strong>toString()</strong>.</p>
518
<p><strong>ValGen</strong> implements the concept of a “generator” which is used a great deal in
519
the C++ STL (<em>Standard Template Library</em>, part of the Standard C++ Library). A
520
generator is an object that produces a new object every time its “generation
521
method” is called, and it is quite convenient for filling containers. Here, I
522
wanted to use it in a <strong>for</strong> iteration, and so I needed the generation method
523
to be the one that is called by the iteration process. This is a special method
524
called <strong>__getitem__()</strong>, which is actually the overloaded operator for
525
indexing, ‘<strong>[ ]</strong>‘. A <strong>for</strong> loop calls this method every time it wants to
526
move the iteration forward, and when the elements run out, <strong>__getitem__()</strong>
527
throws an out-of-bounds exception and that signals the end of the <strong>for</strong> loop
528
(in other languages, you would never use an exception for ordinary control flow,
529
but in Python it seems to work quite well). This exception happens automatically
530
when <strong>self.val[i]</strong> runs out of elements, so the <strong>__getitem__()</strong> code turns
531
out to be simple. The only complexity is that <strong>__getitem__()</strong> appears to
532
return <em>two</em> objects instead of just one. What Python does is automatically
533
package multiple return values into a tuple, so you still only end up returning
534
a single object (in C++ or Java you would have to create your own data structure
535
to accomplish this). In addition, in the <strong>for</strong> loop where <strong>ValGen</strong> is used,
536
Python automatically “unpacks” the tuple so that you can have multiple iterators
537
in the <strong>for</strong>. These are the kinds of syntax simplifications that make Python
538
so endearing.</p>
539
<p>The <strong>jmap</strong> and <strong>jset</strong> objects are instances of Java’s <strong>HashMap</strong> and
540
<strong>HashSet</strong>, again created as if those classes were just native Python
541
components. In the <strong>for</strong> loop, the <strong>put()</strong> and <strong>add()</strong> methods work just
542
like they do in Java. Also, indexing into a Java <strong>Map</strong> uses the same notation
543
as for dictionaries, but note that to iterate through the keys in a <strong>Map</strong> you
544
must use the <strong>Map</strong> method <strong>keySet()</strong> rather than the Python dictionary
545
method <strong>keys()</strong>.</p>
546
<p>The final part of the example shows the use of a Java class that I created from
547
scratch, to demonstrate how trivial it is. Notice also that Jython intuitively
548
understands JavaBeans properties, since you can either use the <strong>getVal()</strong> and
549
<strong>setVal()</strong> methods, or assign to and read from the equivalent <strong>val</strong>
550
property. Also, <strong>getChars()</strong> returns a <strong>Character[]</strong> in Java, and this
551
automatically becomes an array in Python.</p>
552
<p>The easiest way to use Java classes that you create for use inside a Python
553
program is to put them inside a package. Although Jython can also import
554
unpackaged java classes (<strong>import JavaClass</strong>), all such unpackaged java classes
555
will be treated as if they were defined in different packages so they can only
556
see each other’s public methods.</p>
557
<p>Java packages translate into Jython modules, and Jython must import a module in
558
order to be able to use the Java class. Here is the Java code for <strong>JavaClass</strong>:</p>
518
<p>Note that the <strong>import</strong> statements map to the Java package structure
519
exactly as you would expect. In the first example, a <strong>Date()</strong> object
520
is created as if it were a native Python class, and printing this
521
object just calls <strong>toString()</strong>.</p>
522
<p><strong>ValGen</strong> implements the concept of a “generator” which is used a
523
great deal in the C++ STL (<em>Standard Template Library</em>, part of the
524
Standard C++ Library). A generator is an object that produces a new
525
object every time its “generation method” is called, and it is quite
526
convenient for filling containers. Here, I wanted to use it in a
527
<strong>for</strong> iteration, and so I needed the generation method to be the one
528
that is called by the iteration process. This is a special method
529
called <strong>__getitem__()</strong>, which is actually the overloaded operator
530
for indexing, ‘<strong>[ ]</strong>‘. A <strong>for</strong> loop calls this method every time
531
it wants to move the iteration forward, and when the elements run out,
532
<strong>__getitem__()</strong> throws an out-of-bounds exception and that signals
533
the end of the <strong>for</strong> loop (in other languages, you would never use
534
an exception for ordinary control flow, but in Python it seems to work
535
quite well). This exception happens automatically when <strong>self.val[i]</strong>
536
runs out of elements, so the <strong>__getitem__()</strong> code turns out to be
537
simple. The only complexity is that <strong>__getitem__()</strong> appears to
538
return <em>two</em> objects instead of just one. What Python does is
539
automatically package multiple return values into a tuple, so you
540
still only end up returning a single object (in C++ or Java you would
541
have to create your own data structure to accomplish this). In
542
addition, in the <strong>for</strong> loop where <strong>ValGen</strong> is used, Python
543
automatically “unpacks” the tuple so that you can have multiple
544
iterators in the <strong>for</strong>. These are the kinds of syntax
545
simplifications that make Python so endearing.</p>
546
<p>The <strong>jmap</strong> and <strong>jset</strong> objects are instances of Java’s <strong>HashMap</strong>
547
and <strong>HashSet</strong>, again created as if those classes were just native
548
Python components. In the <strong>for</strong> loop, the <strong>put()</strong> and <strong>add()</strong>
549
methods work just like they do in Java. Also, indexing into a Java
550
<strong>Map</strong> uses the same notation as for dictionaries, but note that to
551
iterate through the keys in a <strong>Map</strong> you must use the <strong>Map</strong> method
552
<strong>keySet()</strong> rather than the Python dictionary method <strong>keys()</strong>.</p>
553
<p>The final part of the example shows the use of a Java class that I
554
created from scratch, to demonstrate how trivial it is. Notice also
555
that Jython intuitively understands JavaBeans properties, since you
556
can either use the <strong>getVal()</strong> and <strong>setVal()</strong> methods, or assign to
557
and read from the equivalent <strong>val</strong> property. Also, <strong>getChars()</strong>
558
returns a <strong>Character[]</strong> in Java, and this automatically becomes an
559
array in Python.</p>
560
<p>The easiest way to use Java classes that you create for use inside a
561
Python program is to put them inside a package. Although Jython can
562
also import unpackaged java classes (<strong>import JavaClass</strong>), all such
563
unpackaged java classes will be treated as if they were defined in
564
different packages so they can only see each other’s public methods.</p>
565
<p>Java packages translate into Jython modules, and Jython must import a
566
module in order to be able to use the Java class. Here is the Java
567
code for <strong>JavaClass</strong>:</p>
559
568
<div class="highlight-java"><div class="highlight"><pre><span class="c">// Jython/javaclass/JavaClass.java</span>
560
569
<span class="k">package</span> <span class="n">Jython</span><span class="o">.</span><span class="na">javaclass</span><span class="o">;</span>
561
570
<span class="k">import</span> <span class="nn">java.util.*</span><span class="o">;</span>
@@ -595,20 +604,21 @@ order to be able to use the Java class.
595
604
<span class="o">}</span>
596
605
</pre></div>
597
606
</div>
598
<p>You can see that this is just an ordinary Java class, without any awareness that
599
it will be used in a Jython program. For this reason, one of the important uses
600
of Jython is in testing Java code <a class="footnote-reference" href="#id4" id="id2">[2]</a>. Because Python is such a powerful,
601
flexible, dynamic language it is an ideal tool for automated test frameworks,
602
without making any changes to the Java code that’s being tested.</p>
607
<p>You can see that this is just an ordinary Java class, without any
608
awareness that it will be used in a Jython program. For this reason,
609
one of the important uses of Jython is in testing Java code
610
<a class="footnote-reference" href="#id4" id="id2">[2]</a>. Because Python is such a powerful, flexible, dynamic language it
611
is an ideal tool for automated test frameworks, without making any
612
changes to the Java code that’s being tested.</p>
603
613
<div class="section" id="inner-classes">
604
614
<h3>Inner Classes<a class="headerlink" href="#inner-classes" title="Permalink to this headline">¶</a></h3>
605
<p>Inner classes becomes attributes on the class object. Instances of <strong>static</strong>
606
inner classes can be created with the usual call:</p>
615
<p>Inner classes becomes attributes on the class object. Instances of
616
<strong>static</strong> inner classes can be created with the usual call:</p>
607
617
<div class="highlight-python"><div class="highlight"><pre><span class="n">com</span><span class="o">.</span><span class="n">foo</span><span class="o">.</span><span class="n">JavaClass</span><span class="o">.</span><span class="n">StaticInnerClass</span><span class="p">()</span>
608
618
</pre></div>
609
619
</div>
610
<p>Non-<strong>static</strong> inner classes must have an outer class instance supplied
611
explicitly as the first argument:</p>
620
<p>Non-<strong>static</strong> inner classes must have an outer class instance
621
supplied explicitly as the first argument:</p>
612
622
<div class="highlight-python"><div class="highlight"><pre><span class="n">com</span><span class="o">.</span><span class="n">foo</span><span class="o">.</span><span class="n">JavaClass</span><span class="o">.</span><span class="n">InnerClass</span><span class="p">(</span><span class="n">com</span><span class="o">.</span><span class="n">foo</span><span class="o">.</span><span class="n">JavaClass</span><span class="p">())</span>
613
623
</pre></div>
614
624
</div>
@@ -616,17 +626,18 @@ explicitly as the first argument:</p>
616
626
</div>
617
627
<div class="section" id="controlling-the-interpreter">
618
628
<h2>Controlling the Interpreter<a class="headerlink" href="#controlling-the-interpreter" title="Permalink to this headline">¶</a></h2>
619
<p>In the rest of this chapter, we shall look at more sophisticated ways to
620
interact with Jython. The simplest way to exercise more control over the
621
<strong>PythonInterpreter</strong> object from within Java is to send data to the
622
interpreter, and pull data back out.</p>
629
<p>In the rest of this chapter, we shall look at more sophisticated ways
630
to interact with Jython. The simplest way to exercise more control
631
over the <strong>PythonInterpreter</strong> object from within Java is to send data
632
to the interpreter, and pull data back out.</p>
623
633
<div class="section" id="putting-data-in">
624
634
<h3>Putting Data In<a class="headerlink" href="#putting-data-in" title="Permalink to this headline">¶</a></h3>
625
<p>To inject data into your Python program, the <strong>PythonInterpreter</strong> class has a
626
deceptively simple method: <strong>set()</strong>. However, <strong>set()</strong> takes many different
627
data types and performs conversions upon them.  The following example is a
628
reasonably thorough exercise of the various <strong>set()</strong> possibilities, along with
629
comments that should give a fairly complete explanation:</p>
635
<p>To inject data into your Python program, the <strong>PythonInterpreter</strong>
636
class has a deceptively simple method: <strong>set()</strong>. However, <strong>set()</strong>
637
takes many different data types and performs conversions upon them.
638
The following example is a reasonably thorough exercise of the various
639
<strong>set()</strong> possibilities, along with comments that should give a fairly
640
complete explanation:</p>
630
641
<div class="highlight-java"><div class="highlight"><pre><span class="c">// Jython/PythonInterpreterSetting.java</span>
631
642
<span class="c">// Passing data from Java to python when using</span>
632
643
<span class="c">// the PythonInterpreter object.</span>
@@ -721,47 +732,51 @@ comments that should give a fairly compl
721
732
<span class="o">}</span>
722
733
</pre></div>
723
734
</div>
724
<p>As usual with Java, the distinction between real objects and primitive types
725
causes trouble. In general, if you pass a regular object to <strong>set()</strong>, it knows
726
what to do with it, but if you want to pass in a primitive you must perform a
727
conversion. One way to do this is to create a “Py” type, such as <strong>PyInteger</strong>
728
or <strong>PyFloat</strong>. but it turns out you can also use Java’s own object wrappers
729
like <strong>Integer</strong> and <strong>Float</strong>, which is probably going to be a lot easier to
730
remember.</p>
731
<p>Early in the program you’ll see an <strong>exec()</strong> containing the Python statement:</p>
735
<p>As usual with Java, the distinction between real objects and primitive
736
types causes trouble. In general, if you pass a regular object to
737
<strong>set()</strong>, it knows what to do with it, but if you want to pass in a
738
primitive you must perform a conversion. One way to do this is to
739
create a “Py” type, such as <strong>PyInteger</strong> or <strong>PyFloat</strong>. but it turns
740
out you can also use Java’s own object wrappers like <strong>Integer</strong> and
741
<strong>Float</strong>, which is probably going to be a lot easier to remember.</p>
742
<p>Early in the program you’ll see an <strong>exec()</strong> containing the Python
743
statement:</p>
732
744
<div class="highlight-python"><div class="highlight"><pre><span class="k">print</span><span class="p">(</span><span class="n">a</span><span class="p">[</span><span class="mf">5</span><span class="p">:])</span>
733
745
</pre></div>
734
746
</div>
735
<p>The colon inside the indexing statement indicates a Python <em>slice</em>, which
736
produces a range of elements from the original array. In this case, it produces
737
an array containing the elements from number 5 until the end of the array. You
738
could also say ‘<strong>a[3:5]</strong>‘ to produce elements 3 through 5, or ‘<strong>a[:5]</strong>‘ to
739
produce the elements zero through 5. The reason a slice is used in this
740
statement is to make sure that the Java <strong>String</strong> has really been converted to
741
a Python string, which can also be treated as an array of characters.</p>
742
<p>You can see that it’s possible, using <strong>exec()</strong>, to create a Python function
743
(although it’s a bit awkward). The <strong>prt()</strong> function prints the whole array,
744
and then (to make sure it’s a real Python array), iterates through each element
745
of the array and prints it. Finally, it prints the class of the array, so we can
746
see what conversion has taken place (Python not only has run-time type
747
information, it also has the equivalent of Java reflection). The <strong>prt()</strong>
748
function is used to print arrays that come from each of the Java primitive
749
types.</p>
750
<p>Although a Java <strong>ArrayList</strong> does pass into the interpreter using <strong>set()</strong>,
751
and you can index into it as if it were an array, trying to create a slice
752
fails. To completely convert it into an array, one approach is to simply extract
753
a Java array using <strong>toArray()</strong>, and pass that in. The <strong>set()</strong> method
754
converts it to a <strong>PyArray</strong> – one of the classes provided with Jython – which
755
can be treated as a Python array (you can also explicitly create a <strong>PyArray</strong>,
756
but this seems unnecessary).</p>
757
<p>Finally, a <strong>Map</strong> is created and passed directly into the interpreter. While it
758
is possible to do simple things like index into the resulting object, it’s not a
759
real Python dictionary so you can’t (for example) call the <strong>keys()</strong> method.
760
There is no straightforward way to convert a Java <strong>Map</strong> into a Python
761
dictionary, and so I wrote a utility called <strong>toPyDictionary()</strong> and made it a
762
<strong>static</strong> method of <strong>net.mindview.python.PyUtil</strong>. This also includes
763
utilities to extract a Python array into a Java <strong>List</strong>, and a Python
764
dictionary into a Java <strong>Map</strong>:</p>
747
<p>The colon inside the indexing statement indicates a Python <em>slice</em>,
748
which produces a range of elements from the original array. In this
749
case, it produces an array containing the elements from number 5 until
750
the end of the array. You could also say ‘<strong>a[3:5]</strong>‘ to produce
751
elements 3 through 5, or ‘<strong>a[:5]</strong>‘ to produce the elements zero
752
through 5. The reason a slice is used in this statement is to make
753
sure that the Java <strong>String</strong> has really been converted to a Python
754
string, which can also be treated as an array of characters.</p>
755
<p>You can see that it’s possible, using <strong>exec()</strong>, to create a Python
756
function (although it’s a bit awkward). The <strong>prt()</strong> function prints
757
the whole array, and then (to make sure it’s a real Python array),
758
iterates through each element of the array and prints it. Finally, it
759
prints the class of the array, so we can see what conversion has taken
760
place (Python not only has run-time type information, it also has the
761
equivalent of Java reflection). The <strong>prt()</strong> function is used to
762
print arrays that come from each of the Java primitive types.</p>
763
<p>Although a Java <strong>ArrayList</strong> does pass into the interpreter using
764
<strong>set()</strong>, and you can index into it as if it were an array, trying to
765
create a slice fails. To completely convert it into an array, one
766
approach is to simply extract a Java array using <strong>toArray()</strong>, and
767
pass that in. The <strong>set()</strong> method converts it to a <strong>PyArray</strong> – one
768
of the classes provided with Jython – which can be treated as a
769
Python array (you can also explicitly create a <strong>PyArray</strong>, but this
770
seems unnecessary).</p>
771
<p>Finally, a <strong>Map</strong> is created and passed directly into the
772
interpreter. While it is possible to do simple things like index into
773
the resulting object, it’s not a real Python dictionary so you can’t
774
(for example) call the <strong>keys()</strong> method.  There is no straightforward
775
way to convert a Java <strong>Map</strong> into a Python dictionary, and so I wrote
776
a utility called <strong>toPyDictionary()</strong> and made it a <strong>static</strong> method
777
of <strong>net.mindview.python.PyUtil</strong>. This also includes utilities to
778
extract a Python array into a Java <strong>List</strong>, and a Python dictionary
779
into a Java <strong>Map</strong>:</p>
765
780
<div class="highlight-java"><div class="highlight"><pre><span class="c">// Jython/PyUtil.java</span>
766
781
<span class="c">// PythonInterpreter utilities</span>
767
782
<span class="k">import</span> <span class="nn">org.python.util.PythonInterpreter</span><span class="o">;</span>
@@ -869,22 +884,25 @@ dictionary into a Java <strong>Map</stro
869
884
<div class="section" id="getting-data-out">
870
885
<h3>Getting Data Out<a class="headerlink" href="#getting-data-out" title="Permalink to this headline">¶</a></h3>
871
886
<p>There are a number of different ways to extract data from the
872
<strong>PythonInterpreter</strong>. If you simply call the <strong>get()</strong> method, passing it the
873
object identifier as a string, it returns a <strong>PyObject</strong> (part of the
874
<strong>org.python.core</strong> support classes). It’s possible to “cast” it using the
875
<strong>__tojava__()</strong> method, but there are better alternatives:</p>
887
<strong>PythonInterpreter</strong>. If you simply call the <strong>get()</strong> method,
888
passing it the object identifier as a string, it returns a
889
<strong>PyObject</strong> (part of the <strong>org.python.core</strong> support classes). It’s
890
possible to “cast” it using the <strong>__tojava__()</strong> method, but there are
891
better alternatives:</p>
876
892
<ol class="arabic simple">
877
<li>The convenience methods in the <strong>Py</strong> class, such as <strong>py2int()</strong>, take a
878
<strong>PyObject</strong> and convert it to a number of different types.</li>
879
<li>An overloaded version of <strong>get()</strong> takes the desired Java <strong>Class</strong> object
880
as a second argument, and produces an object that has that run-time type (so you
881
still need to perform a cast on the result in your Java code).</li>
893
<li>The convenience methods in the <strong>Py</strong> class, such as <strong>py2int()</strong>,
894
take a <strong>PyObject</strong> and convert it to a number of different types.</li>
895
<li>An overloaded version of <strong>get()</strong> takes the desired Java
896
<strong>Class</strong> object as a second argument, and produces an object that
897
has that run-time type (so you still need to perform a cast on the
898
result in your Java code).</li>
882
899
</ol>
883
<p>Using the second approach, getting an array from the <strong>PythonInterpreter</strong> is
884
quite easy. This is especially useful because Python is exceptionally good at
885
manipulating strings and files, and so you will commonly want to extract the
886
results as an array of strings. For example, you can do a wildcard expansion of
887
file names using Python’s <strong>glob()</strong>, as shown further down in the following
900
<p>Using the second approach, getting an array from the
901
<strong>PythonInterpreter</strong> is quite easy. This is especially useful because
902
Python is exceptionally good at manipulating strings and files, and so
903
you will commonly want to extract the results as an array of
904
strings. For example, you can do a wildcard expansion of file names
905
using Python’s <strong>glob()</strong>, as shown further down in the following
888
906
code:</p>
889
907
<div class="highlight-java"><div class="highlight"><pre><span class="c">// Jython/PythonInterpreterGetting.java</span>
890
908
<span class="c">// Getting data from the PythonInterpreter object.</span>
@@ -989,18 +1007,20 @@ code:</p>
989
1007
<span class="o">}</span>
990
1008
</pre></div>
991
1009
</div>
992
<p>The last two examples show the extraction of Python tuples and lists into Java
993
<strong>List</strong>s, and Python dictionaries into Java <strong>Map</strong>s. Both of these cases
994
require more processing than is provided in the standard Jython library, so I
995
have again created utilities in <strong>net.mindview.pyton.PyUtil</strong>: <strong>toList()</strong> to
996
produce a <strong>List</strong> from a Python sequence, and <strong>toMap()</strong> to produce a <strong>Map</strong>
997
from a Python dictionary. The <strong>PyUtil</strong> methods make it easier to take
998
important data structures back and forth between Java and Python.</p>
1010
<p>The last two examples show the extraction of Python tuples and lists
1011
into Java <strong>List</strong>s, and Python dictionaries into Java
1012
<strong>Map</strong>s. Both of these cases require more processing than is
1013
provided in the standard Jython library, so I have again created
1014
utilities in <strong>net.mindview.pyton.PyUtil</strong>: <strong>toList()</strong> to produce a
1015
<strong>List</strong> from a Python sequence, and <strong>toMap()</strong> to produce a <strong>Map</strong>
1016
from a Python dictionary. The <strong>PyUtil</strong> methods make it easier to
1017
take important data structures back and forth between Java and Python.</p>
999
1018
</div>
1000
1019
<div class="section" id="multiple-interpreters">
1001
1020
<h3>Multiple Interpreters<a class="headerlink" href="#multiple-interpreters" title="Permalink to this headline">¶</a></h3>
1002
<p>It’s also worth noting that you can have multiple <strong>PythonInterpreter</strong> objects
1003
in a program, and each one has its own name space:</p>
1021
<p>It’s also worth noting that you can have multiple
1022
<strong>PythonInterpreter</strong> objects in a program, and each one has its own
1023
name space:</p>
1004
1024
<div class="highlight-java"><div class="highlight"><pre><span class="c">// Jython/MultipleJythons.java</span>
1005
1025
<span class="c">// You can run multiple interpreters, each</span>
1006
1026
<span class="c">// with its own name space.</span>
@@ -1025,8 +1045,8 @@ in a program, and each one has its own n
1025
1045
<span class="o">}</span>
1026
1046
</pre></div>
1027
1047
</div>
1028
<p>When you run the program you’ll see that the value of <strong>a</strong> is distinct within
1029
each <strong>PythonInterpreter</strong>.</p>
1048
<p>When you run the program you’ll see that the value of <strong>a</strong> is
1049
distinct within each <strong>PythonInterpreter</strong>.</p>
1030
1050
</div>
1031
1051
</div>
1032
1052
<div class="section" id="creating-java-classes-with-jython">
@@ -1043,8 +1063,8 @@ directly into java (via generated proxie
1043
1063
code. This can produce very useful results, as you are then able to
1044
1064
treat the results as if they are native Java classes, albeit with
1045
1065
Python power under the hood.</p>
1046
<p>To produce Java classes from Python code, Jython comes with a compiler called
1047
<strong>jythonc</strong>.</p>
1066
<p>To produce Java classes from Python code, Jython comes with a compiler
1067
called <strong>jythonc</strong>.</p>
1048
1068
<p>The process of creating Python classes that will produce Java classes
1049
1069
is a bit more complex than when calling Java classes from Python,
1050
1070
because the methods in Java classes are statically typed, while Python
@@ -1058,27 +1078,28 @@ standard location for the Python documen
1058
1078
    <span class="s">"@sig public java.lang.String[] returnArray()"</span>
1059
1079
</pre></div>
1060
1080
</div>
1061
<p>The Python definition doesn’t specify any return type, but the @sig string gives
1062
the full type information about what is being passed and returned. The
1063
<strong>jythonc</strong> compiler uses this information to generate the correct Java code.</p>
1064
<p>There’s one other set of rules you must follow in order to get a successful
1065
compilation: you must inherit from a Java class or interface in your Python
1066
class (you do not need to specify the <strong>@sig</strong> signature for methods defined in
1067
the superclass/interface). If you do not do this, you won’t get your desired
1068
methods – unfortunately, <strong>jythonc</strong> gives you no warnings or errors in this
1069
case, but you won’t get what you want. If you don’t see what’s missing, it can
1070
be very frustrating.</p>
1071
<p>In addition, you must import the appropriate java class and give the correct
1072
package specification.  In the example below, <strong>java</strong> is imported so you must
1073
inherit from <strong>java.lang.Object</strong>, but you could also say <strong>from java.lang
1074
import Object</strong> and then you’d just inherit from <strong>Object</strong> without the package
1075
specification. Unfortunately, you don’t get any warnings or errors if you get
1076
this wrong, so you must be patient and keep trying.</p>
1077
<p>Here is an example of a Python class created to produce a Java class. This also
1078
introduces the ‘<strong>=T</strong>‘ directive for the makefile builder tool, which specifies
1079
a different target than the one that is normally used by the tool. In this case,
1080
the Python file is used to build a Java <strong>.class</strong> file, so the class file is
1081
the desired target:</p>
1081
<p>The Python definition doesn’t specify any return type, but the @sig
1082
string gives the full type information about what is being passed and
1083
returned. The <strong>jythonc</strong> compiler uses this information to generate
1084
the correct Java code.</p>
1085
<p>There’s one other set of rules you must follow in order to get a
1086
successful compilation: you must inherit from a Java class or
1087
interface in your Python class (you do not need to specify the
1088
<strong>@sig</strong> signature for methods defined in the
1089
superclass/interface). If you do not do this, you won’t get your
1090
desired methods – unfortunately, <strong>jythonc</strong> gives you no warnings or
1091
errors in this case, but you won’t get what you want. If you don’t see
1092
what’s missing, it can be very frustrating.</p>
1093
<p>In addition, you must import the appropriate java class and give the
1094
correct package specification.  In the example below, <strong>java</strong> is
1095
imported so you must inherit from <strong>java.lang.Object</strong>, but you could
1096
also say <strong>from java.lang import Object</strong> and then you’d just inherit
1097
from <strong>Object</strong> without the package specification. Unfortunately, you
1098
don’t get any warnings or errors if you get this wrong, so you must be
1099
patient and keep trying.</p>
1100
<p>Here is an example of a Python class created to produce a Java
1101
class. In this case, the Python file is used to build a Java
1102
<strong>.class</strong> file, so the class file is the desired target:</p>
1082
1103
<div class="highlight-python"><pre># Jython/PythonToJavaClass.py
1083
1104
# A Python class converted into a Java class
1084
1105
# Compile with:
@@ -1155,29 +1176,33 @@ class PythonToJavaClass(java.lang.Object
1155
1176
        for x in m.keys():
1156
1177
            print(x, m[x])</pre>
1157
1178
</div>
1158
<p>First note that <strong>PythonToJavaClass</strong> is inherited from <strong>java.lang.Object</strong>; if
1159
you don’t do this you will quietly get a Java class without the right
1160
signatures. You are not required to inherit from <strong>Object</strong>; any other Java
1161
class will do.</p>
1162
<p>This class is designed to demonstrate different  arguments and return values, to
1163
provide you with enough examples that you’ll be able to easily create your own
1164
signature strings. The first three of these are fairly self-explanatory, but
1165
note the full qualification of the Java name in the signature string.</p>
1166
<p>In <strong>returnArray()</strong>, a Python array must be returned as a Java array. To do
1167
this, the Jython <strong>array()</strong> function (from the <strong>jarray</strong> module) must be
1168
used, along with the type of the class for the resulting array. Any time you
1169
need to return an array to Java, you must use <strong>array()</strong>, as seen in the
1170
methods <strong>ints()</strong> and <strong>doubles()</strong>.</p>
1171
<p>The last methods show how to pass arguments in from Java. Basic types happen
1172
automatically as long as you specify them in the <strong>@sig</strong> string, but you must
1173
use objects and you cannot pass in primitives (that is, primitives must be
1174
ensconced in wrapper objects, such as <strong>Integer</strong>).</p>
1175
<p>In <strong>argIn3()</strong>, you can see that a Java <strong>List</strong> is transparently converted to
1176
something that behaves just like a Python array, but is not a true array because
1177
you cannot take a slice from it. If you want a true Python array, then you must
1178
create and pass a <strong>PyArray</strong> as in <strong>argIn4()</strong>, where the slice is
1179
successful. Similarly, a Java <strong>Map</strong> must come in as a <strong>PyDictionary</strong> in
1180
order to be treated as a Python dictionary.</p>
1179
<p>First note that <strong>PythonToJavaClass</strong> is inherited from
1180
<strong>java.lang.Object</strong>; if you don’t do this you will quietly get a Java
1181
class without the right signatures. You are not required to inherit
1182
from <strong>Object</strong>; any other Java class will do.</p>
1183
<p>This class is designed to demonstrate different arguments and return
1184
values, to provide you with enough examples that you’ll be able to
1185
easily create your own signature strings. The first three of these are
1186
fairly self-explanatory, but note the full qualification of the Java
1187
name in the signature string.</p>
1188
<p>In <strong>returnArray()</strong>, a Python array must be returned as a Java
1189
array. To do this, the Jython <strong>array()</strong> function (from the
1190
<strong>jarray</strong> module) must be used, along with the type of the class for
1191
the resulting array. Any time you need to return an array to Java, you
1192
must use <strong>array()</strong>, as seen in the methods <strong>ints()</strong> and
1193
<strong>doubles()</strong>.</p>
1194
<p>The last methods show how to pass arguments in from Java. Basic types
1195
happen automatically as long as you specify them in the <strong>@sig</strong>
1196
string, but you must use objects and you cannot pass in primitives
1197
(that is, primitives must be ensconced in wrapper objects, such as
1198
<strong>Integer</strong>).</p>
1199
<p>In <strong>argIn3()</strong>, you can see that a Java <strong>List</strong> is transparently
1200
converted to something that behaves just like a Python array, but is
1201
not a true array because you cannot take a slice from it. If you want
1202
a true Python array, then you must create and pass a <strong>PyArray</strong> as in
1203
<strong>argIn4()</strong>, where the slice is successful. Similarly, a Java <strong>Map</strong>
1204
must come in as a <strong>PyDictionary</strong> in order to be treated as a Python
1205
dictionary.</p>
1181
1206
<p>Here is the Java program to exercise the Java classes produced by the
1182
1207
above Python code. You can’t compile <strong>TestPythonToJavaClass.java</strong>
1183
1208
until <strong>PythonToJavaClass.class</strong> is available:</p>
@@ -1230,28 +1255,30 @@ until <strong>PythonToJavaClass.class</s
1230
1255
</div>
1231
1256
<p>For Python support, you’ll usually only need to import the classes in
1232
1257
<strong>org.python.core</strong>. Everything else in the above example is fairly
1233
straightforward, as <strong>PythonToJavaClass</strong> appears, from the Java side, to be
1234
just another Java class. <strong>dumpClassInfo()</strong> uses reflection to verify that the
1235
method signatures specified in <strong>PythonToJavaClass.py</strong> have come through
1236
properly.</p>
1258
straightforward, as <strong>PythonToJavaClass</strong> appears, from the Java side,
1259
to be just another Java class. <strong>dumpClassInfo()</strong> uses reflection to
1260
verify that the method signatures specified in
1261
<strong>PythonToJavaClass.py</strong> have come through properly.</p>
1237
1262
<div class="section" id="building-java-classes-from-python">
1238
1263
<h3>Building Java Classes from Python<a class="headerlink" href="#building-java-classes-from-python" title="Permalink to this headline">¶</a></h3>
1239
<p>Part of the trick of creating Java classes from Python code is the @sig
1240
information in the method documentation strings. But there’s a second problem
1241
which stems from the fact that Python has no “package” keyword – the Python
1242
equivalent of packages (modules) are implicitly created based on the file name.
1243
However, to bring the resulting class files into the Java program, <strong>jythonc</strong>
1244
must be given information about how to create the Java package for the Python
1245
code. This is done on the <strong>jythonc</strong> command line using the <strong>–package</strong> flag,
1246
followed by the package name you wish to produce (including the separation dots,
1247
just as you would give the package name using the <strong>package</strong> keyword in a Java
1248
program). This will put the resulting <strong>.class</strong> files in the appropriate
1249
subdirectory off of the current directory. Then you only need to import the
1250
package in your Java program, as shown above (you’ll need ‘<strong>.</strong>‘ in your
1251
CLASSPATH in order to run it from the code directory).</p>
1252
<p>Here are the <strong>make</strong> dependency rules that I used to build the above example
1253
(the backslashes at the ends of the lines are understood by <strong>make</strong> to be line
1254
continuations):</p>
1264
<p>Part of the trick of creating Java classes from Python code is the
1265
@sig information in the method documentation strings. But there’s a
1266
second problem which stems from the fact that Python has no “package”
1267
keyword – the Python equivalent of packages (modules) are implicitly
1268
created based on the file name.  However, to bring the resulting class
1269
files into the Java program, <strong>jythonc</strong> must be given information
1270
about how to create the Java package for the Python code. This is done
1271
on the <strong>jythonc</strong> command line using the <strong>–package</strong> flag, followed
1272
by the package name you wish to produce (including the separation
1273
dots, just as you would give the package name using the <strong>package</strong>
1274
keyword in a Java program). This will put the resulting <strong>.class</strong>
1275
files in the appropriate subdirectory off of the current
1276
directory. Then you only need to import the package in your Java
1277
program, as shown above (you’ll need ‘<strong>.</strong>‘ in your CLASSPATH in
1278
order to run it from the code directory).</p>
1279
<p>Here are the <strong>make</strong> dependency rules that I used to build the above
1280
example (the backslashes at the ends of the lines are understood by
1281
<strong>make</strong> to be line continuations):</p>
1255
1282
<div class="highlight-python"><pre>TestPythonToJavaClass.class: \\
1256
1283
        TestPythonToJavaClass.java \\
1257
1284
        python\java\test\PythonToJavaClass.class
@@ -1263,24 +1290,26 @@ python\java\test\PythonToJavaClass.class
1263
1290
    PythonToJavaClass.py</pre>
1264
1291
</div>
1265
1292
<p>The first target, <strong>TestPythonToJavaClass.class</strong>, depends on both
1266
<strong>TestPythonToJavaClass.java</strong> and the <strong>PythonToJavaClass.class</strong>, which is the
1267
Python code that’s converted to a class file. This latter, in turn, depends on
1268
the Python source code. Note that it’s important that the directory where the
1269
target lives be specified, so that the makefile will create the Java program
1270
with the minimum necessary amount of rebuilding.</p>
1293
<strong>TestPythonToJavaClass.java</strong> and the <strong>PythonToJavaClass.class</strong>,
1294
which is the Python code that’s converted to a class file. This
1295
latter, in turn, depends on the Python source code. Note that it’s
1296
important that the directory where the target lives be specified, so
1297
that the makefile will create the Java program with the minimum
1298
necessary amount of rebuilding.</p>
1271
1299
</div>
1272
1300
</div>
1273
1301
<div class="section" id="summary">
1274
1302
<h2>Summary<a class="headerlink" href="#summary" title="Permalink to this headline">¶</a></h2>
1275
<p>This chapter has arguably gone much deeper into Jython than required to use the
1276
interpreter design pattern. Indeed, once you decide that you need to use
1277
interpreter and that you’re not going to get lost inventing your own language,
1278
the solution of installing Jython is quite simple, and you can at least get
1279
started by following the <strong>GreenHouseController</strong> example.</p>
1280
<p>Of course, that example is often too simple and you may need something more
1281
sophisticated, often requiring more interesting data to be passed back and
1282
forth. When I encountered the limited documentation, I felt it necessary to come
1283
up with a more thorough examination of Jython.</p>
1303
<p>This chapter has arguably gone much deeper into Jython than required
1304
to use the interpreter design pattern. Indeed, once you decide that
1305
you need to use interpreter and that you’re not going to get lost
1306
inventing your own language, the solution of installing Jython is
1307
quite simple, and you can at least get started by following the
1308
<strong>GreenHouseController</strong> example.</p>
1309
<p>Of course, that example is often too simple and you may need something
1310
more sophisticated, often requiring more interesting data to be passed
1311
back and forth. When I encountered the limited documentation, I felt
1312
it necessary to come up with a more thorough examination of Jython.</p>
1284
1313
<p>In the process, note that there could be another equally powerful
1285
1314
design pattern lurking in here, which could perhaps be called
1286
1315
<em>multiple languages</em> or <em>language hybridizing</em>. This is based on the
@@ -1289,58 +1318,64 @@ better than the other; by combining lang
1289
1318
much faster than with either language by itself. CORBA is another way
1290
1319
to bridge across languages, and at the same time bridging between
1291
1320
computers and operating systems.</p>
1292
<p>To me, Python and Java present a very potent combination for program development
1293
because of Java’s architecture and tool set, and Python’s extremely rapid
1294
development (generally considered to be 5-10 times faster than C++ or Java).
1295
Python is usually slower, however, but even if you end up re-coding parts of
1296
your program for speed, the initial fast development will allow you to more
1297
quickly flesh out the system and uncover and solve the critical sections. And
1298
often, the execution speed of Python is not a problem – in those cases it’s an
1299
even bigger win. A number of commercial products already use Java and Jython,
1300
and because of the terrific productivity leverage I expect to see this happen
1301
more in the future.</p>
1321
<p>To me, Python and Java present a very potent combination for program
1322
development because of Java’s architecture and tool set, and Python’s
1323
extremely rapid development (generally considered to be 5-10 times
1324
faster than C++ or Java).  Python is usually slower, however, but even
1325
if you end up re-coding parts of your program for speed, the initial
1326
fast development will allow you to more quickly flesh out the system
1327
and uncover and solve the critical sections. And often, the execution
1328
speed of Python is not a problem – in those cases it’s an even bigger
1329
win. A number of commercial products already use Java and Jython, and
1330
because of the terrific productivity leverage I expect to see this
1331
happen more in the future.</p>
1302
1332
</div>
1303
1333
<div class="section" id="exercises">
1304
1334
<h2>Exercises<a class="headerlink" href="#exercises" title="Permalink to this headline">¶</a></h2>
1305
1335
<ol class="arabic simple">
1306
<li>Modify <strong>GreenHouseLanguage.py</strong> so that it checks the times for the events
1307
and runs those events at the appropriate times.</li>
1308
<li>Modify <strong>GreenHouseLanguage.py</strong> so that it calls a function for <strong>action</strong>
1309
instead of just printing a string.</li>
1310
<li>Create a Swing application with a <strong>JTextField</strong> (where the user will enter
1311
commands) and a <strong>JTextArea</strong> (where the command results will be displayed).
1312
Connect to a <strong>PythonInterpreter</strong> object so that the output will be sent to
1313
the <strong>JTextArea</strong> (which should scroll). You’ll need to locate the
1314
<strong>PythonInterpreter</strong> command that redirects the output to a Java stream.</li>
1315
<li>Modify <strong>GreenHouseLanguage.py</strong> to add a master controller class (instead
1316
of the static array inside <strong>Event</strong>) and provide a <strong>run()</strong> method for
1317
each of the subclasses. Each <strong>run()</strong> should create and use an object from
1318
the standard Java library during its execution. Modify
1319
<strong>GreenHouseController.java</strong> to use this new class.</li>
1320
<li>Modify the resulting <strong>GreenHouseLanguage.py</strong> from exercise two to produce
1321
Java classes (add the @sig documentation strings to produce the correct Java
1322
signatures, and create a makefile to build the Java <strong>.class</strong> files). Write
1323
a Java program that uses these classes.</li>
1324
<li>Modify <strong>GreenHouseLanguage.py</strong> so that the subclasses of <strong>Event</strong> are not
1325
discrete classes, but are instead <em>generated</em> by a single function which creates
1326
the class and the associated string dynamically.</li>
1336
<li>Modify <strong>GreenHouseLanguage.py</strong> so that it checks the times for
1337
the events and runs those events at the appropriate times.</li>
1338
<li>Modify <strong>GreenHouseLanguage.py</strong> so that it calls a function for
1339
<strong>action</strong> instead of just printing a string.</li>
1340
<li>Create a Swing application with a <strong>JTextField</strong> (where the user
1341
will enter commands) and a <strong>JTextArea</strong> (where the command
1342
results will be displayed).  Connect to a <strong>PythonInterpreter</strong>
1343
object so that the output will be sent to the <strong>JTextArea</strong> (which
1344
should scroll). You’ll need to locate the <strong>PythonInterpreter</strong>
1345
command that redirects the output to a Java stream.</li>
1346
<li>Modify <strong>GreenHouseLanguage.py</strong> to add a master controller class
1347
(instead of the static array inside <strong>Event</strong>) and provide a
1348
<strong>run()</strong> method for each of the subclasses. Each <strong>run()</strong> should
1349
create and use an object from the standard Java library during its
1350
execution. Modify <strong>GreenHouseController.java</strong> to use this new
1351
class.</li>
1352
<li>Modify the resulting <strong>GreenHouseLanguage.py</strong> from exercise two
1353
to produce Java classes (add the @sig documentation strings to
1354
produce the correct Java signatures, and create a makefile to
1355
build the Java <strong>.class</strong> files). Write a Java program that uses
1356
these classes.</li>
1357
<li>Modify <strong>GreenHouseLanguage.py</strong> so that the subclasses of
1358
<strong>Event</strong> are not discrete classes, but are instead <em>generated</em> by
1359
a single function which creates the class and the associated
1360
string dynamically.</li>
1327
1361
</ol>
1328
1362
<p class="rubric">Footnotes</p>
1329
1363
<table class="docutils footnote" frame="void" id="id3" rules="none">
1330
1364
<colgroup><col class="label" /><col /></colgroup>
1331
1365
<tbody valign="top">
1332
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>The original version of this was called <em>JPython</em>, but the project
1333
changed and the name was changed to emphasize the distinctness of the new
1334
version.</td></tr>
1366
<tr><td class="label"><a class="fn-backref" href="#id1">[1]</a></td><td>The original version of this was called <em>JPython</em>, but the
1367
project changed and the name was changed to emphasize the
1368
distinctness of the new version.</td></tr>
1335
1369
</tbody>
1336
1370
</table>
1337
1371
<table class="docutils footnote" frame="void" id="id4" rules="none">
1338
1372
<colgroup><col class="label" /><col /></colgroup>
1339
1373
<tbody valign="top">
1340
<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>Changing the registry setting <strong>python.security.respectJavaAccessibility
1341
= true</strong> to <strong>false</strong> makes testing even more powerful because it allows
1342
the test script to use <em>all</em> methods, even protected and package-
1343
private.</td></tr>
1374
<tr><td class="label"><a class="fn-backref" href="#id2">[2]</a></td><td>Changing the registry setting
1375
<strong>python.security.respectJavaAccessibility = true</strong> to
1376
<strong>false</strong> makes testing even more powerful because it allows
1377
the test script to use <em>all</em> methods, even protected and
1378
package- private.</td></tr>
1344
1379
</tbody>
1345
1380
</table>
1346
1381
</div>
@@ -1360,13 +1395,15 @@ private.</td></tr>
1360
1395
            <h3><a href="index.html">Table Of Contents</a></h3>
1361
1396
            <ul>
1362
1397
<li><a class="reference external" href="">Jython</a><ul>
1363
<li><a class="reference external" href="#interpreter-motivation">Interpreter Motivation</a></li>
1364
1398
<li><a class="reference external" href="#installation">Installation</a><ul>
1365
1399
<li><a class="reference external" href="#getting-the-trunk">Getting the Trunk</a></li>
1366
1400
</ul>
1367
1401
</li>
1368
1402
<li><a class="reference external" href="#scripting">Scripting</a></li>
1403
<li><a class="reference external" href="#interpreter-motivation">Interpreter Motivation</a><ul>
1369
1404
<li><a class="reference external" href="#creating-a-language">Creating a Language</a></li>
1405
</ul>
1406
</li>
1370
1407
<li><a class="reference external" href="#using-java-libraries">Using Java libraries</a><ul>
1371
1408
<li><a class="reference external" href="#inheriting-from-java-library-classes">Inheriting from Java library Classes</a></li>
1372
1409
</ul>
@@ -1433,7 +1470,7 @@ private.</td></tr>
1433
1470
    </div>
1434
1471
    <div class="footer">
1435
1472
      © Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
1436
      Last updated on Dec 30, 2008.
1473
      Last updated on Dec 31, 2008.
1437
1474
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.
1438
1475
    </div>
1439
1476
  </body>

Up to file-list html/ToDo.html:

@@ -118,7 +118,7 @@ for BitBucket & Mercurial; make some
118
118
<p class="last">rewrite to distinguish python generator from above description, or
119
119
choose different name.</p>
120
120
</div>
121
<p>(The original entry is located in Jython.rst, line 492 and can be found <a class="reference external" href="Jython.html#todo-20"><em>here</em></a>.)</p>
121
<p>(The original entry is located in Jython.rst, line 496 and can be found <a class="reference external" href="Jython.html#todo-25"><em>here</em></a>.)</p>
122
122
</div>
123
123
124
124
@@ -180,7 +180,7 @@ choose different name.</p>
180
180
    </div>
181
181
    <div class="footer">
182
182
      © Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
183
      Last updated on Dec 30, 2008.
183
      Last updated on Dec 31, 2008.
184
184
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.
185
185
    </div>
186
186
  </body>

Up to file-list html/_sources/Jython.txt:

@@ -10,66 +10,48 @@ Jython
10
10
   	   that the material can be used to introduce Java programmers to
11
11
	   Jython.
12
12
13
This chapter looks at the value of crossing language boundaries. It is often
14
advantageous to solve a problem using more than one programming language, rather
15
than being arbitrarily stuck using a single language. As you'll see in this
16
chapter, a problem that is very difficult or tedious to solve in one language
17
can often be solved quickly and easily in another. If you can combine the use of
18
languages, you can create your product much more quickly and cheaply.
13
Sometimes it's easier and faster to temporarily step into another
14
language to solve a particular aspect of your problem.
19
15
20
The most straightforward use of this idea is the *Interpreter* design
21
pattern, which adds an interpreted language to your program to allow
22
the end user to easily customize a solution. If the application user
23
needs greater run time flexibility, for example to create scripts
24
describing the desired behavior of the system, you can use
25
*Interpreter* by creating and embedding a language interpreter into
26
your program.
16
This chapter looks at the value of crossing language boundaries. It is
17
often advantageous to solve a problem using more than one programming
18
language; as you'll see, a problem that is very difficult or tedious
19
to solve in one language can often be solved quickly and easily in
20
another. By combining languages, you can create your product much more
21
quickly and cheaply.
22
23
One use of this idea is the *Interpreter* design pattern, which adds
24
an interpreted language to your program to allow the end user to
25
easily customize a solution. If the application user needs greater run
26
time flexibility, for example to create scripts describing the desired
27
behavior of the system, you can use *Interpreter* by creating and
28
embedding a language interpreter into your program.
27
29
28
30
In Java, the easiest and most powerful way to do this is with *Jython*
29
31
[#]_, an implementation of Python in pure Java byte codes. As you will
30
32
see, this brings together the benefits of both worlds.
31
33
32
*Interpreter* solves a particular problem -- that of creating a
33
scripting language for the user. But sometimes it's just easier and
34
faster to temporarily step into another language to solve a particular
35
aspect of your problem. You're not creating an interpreter, you're
36
just writing some code in another language.
37
38
Interpreter Motivation
39
=======================================================================
40
41
Remember that each design pattern allows one or more factors to change, so it's
42
important to first be aware of which factor is changing. Sometimes the end users
43
of your application (rather than the programmers of that application) need
44
complete flexibility in the way that they configure some aspect of the program.
45
That is, they need to do some kind of simple programming. The interpreter
46
pattern provides this flexibility by adding a language interpreter.
47
48
The problem is that developing your own language and building an interpreter is
49
a time-consuming distraction from the process of developing your application.
50
You must ask whether you want to finish writing your application or create a new
51
language.  The best solution is to reuse code: embed an interpreter that's
52
already been built and debugged for you. The Python language can be freely
53
embedded into your for-profit application without signing any license agreement,
54
paying royalties, or dealing with strings of any kind. There are basically no
55
restrictions at all when you're using Python.
56
57
For solving Java problems, we will look at a special version of Python called
58
Jython. This is generated entirely in Java byte codes, so incorporating it into
59
your application is quite simple,  and it's as portable as Java is. It has an
60
extremely clean interface with Java: Java can call Python classes, and Python
61
can call Java classes.
34
Jython is generated entirely in Java byte codes, so incorporating it
35
into your application is quite simple, and it's as portable as Java
36
is. It has an extremely clean interface with Java: Java can call
37
Python classes, and Python can call Java classes.
62
38
63
39
Because Jython is just Java classes, it can often be "stealthed" into
64
40
companies that have rigid processes for using new languges and
65
41
tools. If Java has been accepted, such companies often accept anything
66
42
that runs on the JVM without question.
67
43
68
Python is designed with classes from the ground up and is a truly pure object
69
oriented language (both C++ and Java violate purity in various ways). Python
70
scales up so that you can create very big programs without losing control of the
71
code. Java projects have been quickly created using Jython, then later optimized by
72
rewriting sections of the Jython code that have profiled as bottlenecks into Java.
44
The Python/Jython language can be freely embedded into your for-profit
45
application without signing any license agreement, paying royalties,
46
or dealing with strings of any kind. There are basically no
47
restrictions when you're using Python/Jython.
48
49
Python is designed with classes from the ground up and provides pure
50
support for object-oriented programming (both C++ and Java violate
51
purity in various ways). Python scales up so that you can create large
52
programs without losing control of the code. Java projects have been
53
quickly created using Jython, then later optimized by rewriting into
54
Java sections of the Jython code that have profiled as bottlenecks.
73
55
74
56
Installation
75
57
=======================================================================
@@ -123,7 +105,7 @@ See: http://wiki.python.org/jython/Readl
123
105
Scripting
124
106
=======================================================================
125
107
126
One very compelling benefit of using a dynamic language on the JVM is
108
One compelling benefit of using a dynamic language on the JVM is
127
109
scripting.  You can rapidly create and test code, and solve problems
128
110
more quickly.
129
111
@@ -157,21 +139,21 @@ benefits of the JVM. The total runtime o
157
139
faster because of its rapid startup time; the JVM always has a delay
158
140
for startup.
159
141
160
Note that things that require much more code (and often research) in
161
Java are very quick to write in Jython. Here's an example that uses
162
a Python *list comprehension* with the **os.walk()** function to visit
163
all the directories in a directory tree, and find all the files with names
164
that end in **.java** (of course you can easily do more sophisticated things
165
like opening the file and looking for information within it)::
142
Note that things that are very quick to write in Jython require much
143
more code (and often research) in Java. Here's an example that uses a
144
Python *list comprehension* with the **os.walk()** function to visit
145
all the directories in a directory tree, and find all the files with
146
names that end in **.java** and contain the word **PythonInterpreter**::
166
147
167
     # Jython/Walk_comprehension.py
168
     import os
148
       # Jython/Walk_comprehension.py
149
       import os
169
150
170
     restFiles = [os.path.join(d[0], f) for d in os.walk(".")
171
                  for f in d[2] if f.endswith(".java")]
151
       restFiles = [os.path.join(d[0], f) for d in os.walk(".")
152
       		    for f in d[2] if f.endswith(".java") and
153
                    "PythonInterpreter" in open(os.path.join(d[0], f)).read()]
172
154
173
     for r in restFiles:
174
     	 print(r)
155
       for r in restFiles:
156
       	   print(r)
175
157
176
158
You can certainly achieve this in Java. It will just take a lot longer.
177
159
@@ -179,17 +161,35 @@ Often more sophisticated programs begin
179
161
The fact that you can quickly try things out allows you to test
180
162
concepts, and then create more refined code as needed.
181
163
164
Interpreter Motivation
165
=======================================================================
166
167
Remember that each design pattern allows one or more factors to
168
change, so it's important to first be aware of which factor is
169
changing. Sometimes the end users of your application (rather than the
170
programmers of that application) need complete flexibility in the way
171
that they configure some aspect of the program.  That is, they need to
172
do some kind of simple programming. The *Interpreter* pattern provides
173
this flexibility by adding a language interpreter.
174
175
The problem is that creating your own language and building an
176
interpreter is a time-consuming distraction from the process of
177
developing your application.  You must ask whether you want to finish
178
writing your application or make a new language.  The best solution is
179
to reuse code: embed an interpreter that's already been built and
180
debugged for you.
181
182
182
Creating a Language
183
=======================================================================
183
-------------------------------------------------------------------------
184
184
185
185
It turns out to be remarkably simple to use Jython to create an
186
186
interpreted language inside your application. Consider the greenhouse
187
187
controller example from *Thinking in Java*. This is a situation where
188
188
you want the end user -- the person managing the greenhouse -- to have
189
189
configuration control over the system, and so a simple scripting
190
language is the ideal solution.  This is often called a
191
*domain-specific language* (DSL) because it solves a particular
192
domain problem.
190
language is an ideal solution.  This is often called a
191
*domain-specific language* (DSL) because it solves a particular domain
192
problem.
193
193
194
194
To create the language, we'll simply write a set of Python classes,
195
195
and the constructor of each will add itself to a (static) master
@@ -268,21 +268,21 @@ but outside of any methods, is what make
268
268
.. note:: To run this program say ``python GreenHouseLanguage.py`` or
269
269
   	  ``jython GreenHouseLanguage.py``.
270
270
271
The constructor of each derived class calls the base-class constructor, which
272
adds the new object to the list. The **run()** function sorts the list, which
273
automatically uses the **__cmp__()** method defined in **Event** to
274
base comparisons on time only. In this example, it only prints out the list, but
275
in the real system it would wait for the time of each event to come up and then
276
run the event.
271
The constructor of each derived class calls the base-class
272
constructor, which adds the new object to the list. The **run()**
273
function sorts the list, which automatically uses the **__cmp__()**
274
method defined in **Event** to base comparisons on time only. In this
275
example, it only prints out the list, but in the real system it would
276
wait for the time of each event to come up and then run the event.
277
277
278
278
The **__main__** section performs a simple test on the classes.
279
279
280
280
The above file -- which is an ordinary Python program -- is now a
281
module that can be included in another Python program.
282
But instead of using it in an ordinary Python program,
283
let's use Jython, inside of Java. This turns out to be remarkably
284
simple: you import some Jython classes, create a **PythonInterpreter**
285
object, and cause the Python files to be loaded:
281
module that can be included in another Python program.  But instead of
282
using it in an ordinary Python program, let's use Jython, inside of
283
Java. This turns out to be remarkably simple: you import some Jython
284
classes, create a **PythonInterpreter** object, and cause the Python
285
files to be loaded:
286
286
287
287
..  code-block:: java
288
288
@@ -302,13 +302,14 @@ object, and cause the Python files to be
302
302
      }
303
303
    }
304
304
305
The **PythonInterpreter** object is a complete Python interpreter that accepts
306
commands from the Java program. One of these commands is **execfile()**, which
307
tells it to execute all the statements it finds in a particular file. By
308
executing **GreenHouseLanguage.py**, all the classes from that file are loaded
309
into our **PythonInterpreter** object, and so it now "holds" the greenhouse
310
controller language. The **Schedule.ghs** file is the one created by the end
311
user to control the greenhouse. Here's an example::
305
The **PythonInterpreter** object is a complete Python interpreter that
306
accepts commands from the Java program. One of these commands is
307
**execfile()**, which tells it to execute all the statements it finds
308
in a particular file. By executing **GreenHouseLanguage.py**, all the
309
classes from that file are loaded into our **PythonInterpreter**
310
object, and so it now "holds" the greenhouse controller language. The
311
**Schedule.ghs** file is the one created by the end user to control
312
the greenhouse. Here's an example::
312
313
313
314
    # Jython/Schedule.ghs
314
315
    Bell(7.00)
@@ -319,9 +320,9 @@ user to control the greenhouse. Here's a
319
320
    LightOff(2.00)
320
321
    WaterOff(4.45)
321
322
322
This is the goal of the interpreter design pattern: to make the configuration of
323
your program as simple as possible for the end user. With Jython you can achieve
324
this with almost no effort at all.
323
This is the goal of the interpreter design pattern: to make the
324
configuration of your program as simple as possible for the end
325
user. With Jython you can achieve this with almost no effort at all.
325
326
326
327
One of the other methods available to the **PythonInterpreter** is
327
328
**exec()**, which allows you to send a command to the interpreter. In
@@ -330,11 +331,11 @@ the above program, the **run()** functio
330
331
Using Java libraries
331
332
=======================================================================
332
333
333
Jython wraps the Java libraries so that any of them can be used directly or via
334
inheritance. In addition, Python shorthand simplifies coding.
334
Jython wraps Java libraries so that any of them can be used directly
335
or via inheritance. In addition, Python shorthand simplifies coding.
335
336
336
As an example, consider the **HTMLButton.java** example from
337
*Thinking in Java*. Here is its conversion to Jython::
337
As an example, consider the **HTMLButton.java** example from *Thinking
338
in Java*. Here is its conversion to Jython::
338
339
339
340
    # Jython/PythonSwing.py
340
341
    # The HTMLButton.java example from "Thinking in Java"
@@ -361,21 +362,23 @@ As an example, consider the **HTMLButton
361
362
    frame.size=200, 500
362
363
363
364
If you compare the Java version of the program to the above Jython
364
implementation, you'll see that Jython is shorter and generally easier to
365
understand. For example, to set up the frame in the Java version you had to make
366
several calls: the constructor for **JFrame()**, the **setVisible()** method
367
and the **setDefaultCloseOperation()** method, whereas in the above code all
368
three of these operations are performed with a single constructor call.
365
implementation, you'll see that Jython is shorter and generally easier
366
to understand. For example, to set up the frame in the Java version
367
you had to make several calls: the constructor for **JFrame()**, the
368
**setVisible()** method and the **setDefaultCloseOperation()** method,
369
whereas in the above code all three of these operations are performed
370
with a single constructor call.
369
371
370
Also notice that the **JButton** is configured with an **actionListener()**
371
method inside the constructor, with the assignment to **kapow**. In addition,
372
Jython's JavaBean awareness means that a call to any method with a name that
373
begins with "**set**" can be replaced with an assignment, as you see above.
372
Also notice that the **JButton** is configured with an
373
**actionListener()** method inside the constructor, with the
374
assignment to **kapow**. In addition, Jython's JavaBean awareness
375
means that a call to any method with a name that begins with "**set**"
376
can be replaced with an assignment, as you see above.
374
377
375
The only method that did not come over from Java is the **pack()** method,
376
which seems to be essential in order to force the layout to happen properly.
377
It's also important that the call to **pack()** appear *before* the **size**
378
setting.
378
The only method that did not come over from Java is the **pack()**
379
method, which seems to be essential in order to force the layout to
380
happen properly.  It's also important that the call to **pack()**
381
appear *before* the **size** setting.
379
382
380
383
Inheriting from Java library Classes
381
384
-------------------------------------------------------------------------------
@@ -409,24 +412,25 @@ converted into Jython::
409
412
    frame.pack()
410
413
411
414
412
**MyDialog** is inherited from **JDialog**, and you can see named arguments
413
being used in the call to the base-class constructor.
415
**MyDialog** is inherited from **JDialog**, and you can see named
416
arguments being used in the call to the base-class constructor.
414
417
415
In the creation of the "OK" **JButton**, note that the **actionPerformed**
416
method is set right inside the constructor, and that the function is created
417
using the Python **lambda** keyword. This creates a nameless function with the
418
arguments appearing before the colon and the expression that generates the
419
returned value after the colon. As you should know, the Java prototype for the
420
**actionPerformed()** method only contains a single argument, but the lambda
421
expression indicates two. However, the second argument is provided with a
422
default value, so the function *can* be called with only one argument. The
423
reason for the second argument is seen in the default value, because this is a
424
way to pass **self** into the lambda expression, so that it can be used to
425
dispose of the dialog.
418
In the creation of the "OK" **JButton**, note that the
419
**actionPerformed** method is set right inside the constructor, and
420
that the function is created using the Python **lambda** keyword. This
421
creates a nameless function with the arguments appearing before the
422
colon and the expression that generates the returned value after the
423
colon. As you should know, the Java prototype for the
424
**actionPerformed()** method only contains a single argument, but the
425
lambda expression indicates two. However, the second argument is
426
provided with a default value, so the function *can* be called with
427
only one argument. The reason for the second argument is seen in the
428
default value, because this is a way to pass **self** into the lambda
429
expression, so that it can be used to dispose of the dialog.
426
430
427
Compare this code with the version that's published in *Thinking in Java*.
428
You'll find that Python language features allow a much more succinct and direct
429
implementation.
431
Compare this code with the version that's published in *Thinking in
432
Java*.  You'll find that Python language features allow a much more
433
succinct and direct implementation.
430
434
431
435
432
436
Controlling Java from Jython
@@ -492,55 +496,61 @@ create yourself, as you can see here::
492
496
..  todo:: rewrite to distinguish python generator from above description, or
493
497
    	   choose different name.
494
498
495
Note that the **import** statements map to the Java package structure exactly as
496
you would expect. In the first example, a **Date()** object is created as if it
497
were a native Python class, and printing this object just calls **toString()**.
499
Note that the **import** statements map to the Java package structure
500
exactly as you would expect. In the first example, a **Date()** object
501
is created as if it were a native Python class, and printing this
502
object just calls **toString()**.
498
503
499
**ValGen** implements the concept of a "generator" which is used a great deal in
500
the C++ STL (*Standard Template Library*, part of the Standard C++ Library). A
501
generator is an object that produces a new object every time its "generation
502
method" is called, and it is quite convenient for filling containers. Here, I
503
wanted to use it in a **for** iteration, and so I needed the generation method
504
to be the one that is called by the iteration process. This is a special method
505
called **__getitem__()**, which is actually the overloaded operator for
506
indexing, '**[ ]**'. A **for** loop calls this method every time it wants to
507
move the iteration forward, and when the elements run out, **__getitem__()**
508
throws an out-of-bounds exception and that signals the end of the **for** loop
509
(in other languages, you would never use an exception for ordinary control flow,
510
but in Python it seems to work quite well). This exception happens automatically
511
when **self.val[i]** runs out of elements, so the **__getitem__()** code turns
512
out to be simple. The only complexity is that **__getitem__()** appears to
513
return *two* objects instead of just one. What Python does is automatically
514
package multiple return values into a tuple, so you still only end up returning
515
a single object (in C++ or Java you would have to create your own data structure
516
to accomplish this). In addition, in the **for** loop where **ValGen** is used,
517
Python automatically "unpacks" the tuple so that you can have multiple iterators
518
in the **for**. These are the kinds of syntax simplifications that make Python
519
so endearing.
504
**ValGen** implements the concept of a "generator" which is used a
505
great deal in the C++ STL (*Standard Template Library*, part of the
506
Standard C++ Library). A generator is an object that produces a new
507
object every time its "generation method" is called, and it is quite
508
convenient for filling containers. Here, I wanted to use it in a
509
**for** iteration, and so I needed the generation method to be the one
510
that is called by the iteration process. This is a special method
511
called **__getitem__()**, which is actually the overloaded operator
512
for indexing, '**[ ]**'. A **for** loop calls this method every time
513
it wants to move the iteration forward, and when the elements run out,
514
**__getitem__()** throws an out-of-bounds exception and that signals
515
the end of the **for** loop (in other languages, you would never use
516
an exception for ordinary control flow, but in Python it seems to work
517
quite well). This exception happens automatically when **self.val[i]**
518
runs out of elements, so the **__getitem__()** code turns out to be
519
simple. The only complexity is that **__getitem__()** appears to
520
return *two* objects instead of just one. What Python does is
521
automatically package multiple return values into a tuple, so you
522
still only end up returning a single object (in C++ or Java you would
523
have to create your own data structure to accomplish this). In
524
addition, in the **for** loop where **ValGen** is used, Python
525
automatically "unpacks" the tuple so that you can have multiple
526
iterators in the **for**. These are the kinds of syntax
527
simplifications that make Python so endearing.
520
528
521
The **jmap** and **jset** objects are instances of Java's **HashMap** and
522
**HashSet**, again created as if those classes were just native Python
523
components. In the **for** loop, the **put()** and **add()** methods work just
524
like they do in Java. Also, indexing into a Java **Map** uses the same notation
525
as for dictionaries, but note that to iterate through the keys in a **Map** you
526
must use the **Map** method **keySet()** rather than the Python dictionary
527
method **keys()**.
529
The **jmap** and **jset** objects are instances of Java's **HashMap**
530
and **HashSet**, again created as if those classes were just native
531
Python components. In the **for** loop, the **put()** and **add()**
532
methods work just like they do in Java. Also, indexing into a Java
533
**Map** uses the same notation as for dictionaries, but note that to
534
iterate through the keys in a **Map** you must use the **Map** method
535
**keySet()** rather than the Python dictionary method **keys()**.
528
536
529
The final part of the example shows the use of a Java class that I created from
530
scratch, to demonstrate how trivial it is. Notice also that Jython intuitively
531
understands JavaBeans properties, since you can either use the **getVal()** and
532
**setVal()** methods, or assign to and read from the equivalent **val**
533
property. Also, **getChars()** returns a **Character[]** in Java, and this
534
automatically becomes an array in Python.
537
The final part of the example shows the use of a Java class that I
538
created from scratch, to demonstrate how trivial it is. Notice also
539
that Jython intuitively understands JavaBeans properties, since you
540
can either use the **getVal()** and **setVal()** methods, or assign to
541
and read from the equivalent **val** property. Also, **getChars()**
542
returns a **Character[]** in Java, and this automatically becomes an
543
array in Python.
535
544
536
The easiest way to use Java classes that you create for use inside a Python
537
program is to put them inside a package. Although Jython can also import
538
unpackaged java classes (**import JavaClass**), all such unpackaged java classes
539
will be treated as if they were defined in different packages so they can only
540
see each other's public methods.
545
The easiest way to use Java classes that you create for use inside a
546
Python program is to put them inside a package. Although Jython can
547
also import unpackaged java classes (**import JavaClass**), all such
548
unpackaged java classes will be treated as if they were defined in
549
different packages so they can only see each other's public methods.
541
550
542
Java packages translate into Jython modules, and Jython must import a module in
543
order to be able to use the Java class. Here is the Java code for **JavaClass**:
551
Java packages translate into Jython modules, and Jython must import a
552
module in order to be able to use the Java class. Here is the Java
553
code for **JavaClass**:
544
554
545
555
..  code-block:: java
546
556
@@ -582,41 +592,43 @@ order to be able to use the Java class.
582
592
      }
583
593
    }
584
594
585
You can see that this is just an ordinary Java class, without any awareness that
586
it will be used in a Jython program. For this reason, one of the important uses
587
of Jython is in testing Java code [#]_. Because Python is such a powerful,
588
flexible, dynamic language it is an ideal tool for automated test frameworks,
589
without making any changes to the Java code that's being tested.
595
You can see that this is just an ordinary Java class, without any
596
awareness that it will be used in a Jython program. For this reason,
597
one of the important uses of Jython is in testing Java code
598
[#]_. Because Python is such a powerful, flexible, dynamic language it
599
is an ideal tool for automated test frameworks, without making any
600
changes to the Java code that's being tested.
590
601
591
602
Inner Classes
592
603
------------------------------------------------------------------------------
593
604
594
Inner classes becomes attributes on the class object. Instances of **static**
595
inner classes can be created with the usual call::
605
Inner classes becomes attributes on the class object. Instances of
606
**static** inner classes can be created with the usual call::
596
607
597
608
    com.foo.JavaClass.StaticInnerClass()
598
609
599
Non-**static** inner classes must have an outer class instance supplied
600
explicitly as the first argument::
610
Non-**static** inner classes must have an outer class instance
611
supplied explicitly as the first argument::
601
612
602
613
    com.foo.JavaClass.InnerClass(com.foo.JavaClass())
603
614
604
615
Controlling the Interpreter
605
616
=======================================================================
606
617
607
In the rest of this chapter, we shall look at more sophisticated ways to
608
interact with Jython. The simplest way to exercise more control over the
609
**PythonInterpreter** object from within Java is to send data to the
610
interpreter, and pull data back out.
618
In the rest of this chapter, we shall look at more sophisticated ways
619
to interact with Jython. The simplest way to exercise more control
620
over the **PythonInterpreter** object from within Java is to send data
621
to the interpreter, and pull data back out.
611
622
612
623
Putting Data In
613
624
--------------------------------------------------------------------------------
614
625
615
To inject data into your Python program, the **PythonInterpreter** class has a
616
deceptively simple method: **set()**. However, **set()** takes many different
617
data types and performs conversions upon them.  The following example is a
618
reasonably thorough exercise of the various **set()** possibilities, along with
619
comments that should give a fairly complete explanation:
626
To inject data into your Python program, the **PythonInterpreter**
627
class has a deceptively simple method: **set()**. However, **set()**
628
takes many different data types and performs conversions upon them.
629
The following example is a reasonably thorough exercise of the various
630
**set()** possibilities, along with comments that should give a fairly
631
complete explanation:
620
632
621
633
..  code-block:: java
622
634
@@ -713,51 +725,55 @@ comments that should give a fairly compl
713
725
      }
714
726
    }
715
727
716
As usual with Java, the distinction between real objects and primitive types
717
causes trouble. In general, if you pass a regular object to **set()**, it knows
718
what to do with it, but if you want to pass in a primitive you must perform a
719
conversion. One way to do this is to create a "Py" type, such as **PyInteger**
720
or **PyFloat**. but it turns out you can also use Java's own object wrappers
721
like **Integer** and **Float**, which is probably going to be a lot easier to
722
remember.
728
As usual with Java, the distinction between real objects and primitive
729
types causes trouble. In general, if you pass a regular object to
730
**set()**, it knows what to do with it, but if you want to pass in a
731
primitive you must perform a conversion. One way to do this is to
732
create a "Py" type, such as **PyInteger** or **PyFloat**. but it turns
733
out you can also use Java's own object wrappers like **Integer** and
734
**Float**, which is probably going to be a lot easier to remember.
723
735
724
Early in the program you'll see an **exec()** containing the Python statement::
736
Early in the program you'll see an **exec()** containing the Python
737
statement::
725
738
726
739
    print(a[5:])
727
740
728
The colon inside the indexing statement indicates a Python *slice*, which
729
produces a range of elements from the original array. In this case, it produces
730
an array containing the elements from number 5 until the end of the array. You
731
could also say '**a[3:5]**' to produce elements 3 through 5, or '**a[:5]**' to
732
produce the elements zero through 5. The reason a slice is used in this
733
statement is to make sure that the Java **String** has really been converted to
734
a Python string, which can also be treated as an array of characters.
741
The colon inside the indexing statement indicates a Python *slice*,
742
which produces a range of elements from the original array. In this
743
case, it produces an array containing the elements from number 5 until
744
the end of the array. You could also say '**a[3:5]**' to produce
745
elements 3 through 5, or '**a[:5]**' to produce the elements zero
746
through 5. The reason a slice is used in this statement is to make
747
sure that the Java **String** has really been converted to a Python
748
string, which can also be treated as an array of characters.
735
749
736
You can see that it's possible, using **exec()**, to create a Python function
737
(although it's a bit awkward). The **prt()** function prints the whole array,
738
and then (to make sure it's a real Python array), iterates through each element
739
of the array and prints it. Finally, it prints the class of the array, so we can
740
see what conversion has taken place (Python not only has run-time type
741
information, it also has the equivalent of Java reflection). The **prt()**
742
function is used to print arrays that come from each of the Java primitive
743
types.
750
You can see that it's possible, using **exec()**, to create a Python
751
function (although it's a bit awkward). The **prt()** function prints
752
the whole array, and then (to make sure it's a real Python array),
753
iterates through each element of the array and prints it. Finally, it
754
prints the class of the array, so we can see what conversion has taken
755
place (Python not only has run-time type information, it also has the
756
equivalent of Java reflection). The **prt()** function is used to
757
print arrays that come from each of the Java primitive types.
744
758
745
Although a Java **ArrayList** does pass into the interpreter using **set()**,
746
and you can index into it as if it were an array, trying to create a slice
747
fails. To completely convert it into an array, one approach is to simply extract
748
a Java array using **toArray()**, and pass that in. The **set()** method
749
converts it to a **PyArray** -- one of the classes provided with Jython -- which
750
can be treated as a Python array (you can also explicitly create a **PyArray**,
751
but this seems unnecessary).
759
Although a Java **ArrayList** does pass into the interpreter using
760
**set()**, and you can index into it as if it were an array, trying to
761
create a slice fails. To completely convert it into an array, one
762
approach is to simply extract a Java array using **toArray()**, and
763
pass that in. The **set()** method converts it to a **PyArray** -- one
764
of the classes provided with Jython -- which can be treated as a
765
Python array (you can also explicitly create a **PyArray**, but this
766
seems unnecessary).
752
767
753
Finally, a **Map** is created and passed directly into the interpreter. While it
754
is possible to do simple things like index into the resulting object, it's not a
755
real Python dictionary so you can't (for example) call the **keys()** method.
756
There is no straightforward way to convert a Java **Map** into a Python
757
dictionary, and so I wrote a utility called **toPyDictionary()** and made it a
758
**static** method of **net.mindview.python.PyUtil**. This also includes
759
utilities to extract a Python array into a Java **List**, and a Python
760
dictionary into a Java **Map**:
768
Finally, a **Map** is created and passed directly into the
769
interpreter. While it is possible to do simple things like index into
770
the resulting object, it's not a real Python dictionary so you can't
771
(for example) call the **keys()** method.  There is no straightforward
772
way to convert a Java **Map** into a Python dictionary, and so I wrote
773
a utility called **toPyDictionary()** and made it a **static** method
774
of **net.mindview.python.PyUtil**. This also includes utilities to
775
extract a Python array into a Java **List**, and a Python dictionary
776
into a Java **Map**:
761
777
762
778
..  code-block:: java
763
779
@@ -815,7 +831,6 @@ dictionary into a Java **Map**:
815
831
      }
816
832
    }
817
833
818
819
834
Here is the unit testing code:
820
835
821
836
..  code-block:: java
@@ -872,24 +887,27 @@ Getting Data Out
872
887
--------------------------------------------------------------------------------
873
888
874
889
There are a number of different ways to extract data from the
875
**PythonInterpreter**. If you simply call the **get()** method, passing it the
876
object identifier as a string, it returns a **PyObject** (part of the
877
**org.python.core** support classes). It's possible to "cast" it using the
878
**__tojava__()** method, but there are better alternatives:
890
**PythonInterpreter**. If you simply call the **get()** method,
891
passing it the object identifier as a string, it returns a
892
**PyObject** (part of the **org.python.core** support classes). It's
893
possible to "cast" it using the **__tojava__()** method, but there are
894
better alternatives:
879
895
880
896
881
1.  The convenience methods in the **Py** class, such as **py2int()**, take a
882
    **PyObject** and convert it to a number of different types.
897
1.  The convenience methods in the **Py** class, such as **py2int()**,
898
    take a **PyObject** and convert it to a number of different types.
883
899
884
2.  An overloaded version of **get()** takes the desired Java **Class** object
885
    as a second argument, and produces an object that has that run-time type (so you
886
    still need to perform a cast on the result in your Java code).
900
2.  An overloaded version of **get()** takes the desired Java
901
    **Class** object as a second argument, and produces an object that
902
    has that run-time type (so you still need to perform a cast on the
903
    result in your Java code).
887
904
888
Using the second approach, getting an array from the **PythonInterpreter** is
889
quite easy. This is especially useful because Python is exceptionally good at
890
manipulating strings and files, and so you will commonly want to extract the
891
results as an array of strings. For example, you can do a wildcard expansion of
892
file names using Python's **glob()**, as shown further down in the following
905
Using the second approach, getting an array from the
906
**PythonInterpreter** is quite easy. This is especially useful because
907
Python is exceptionally good at manipulating strings and files, and so
908
you will commonly want to extract the results as an array of
909
strings. For example, you can do a wildcard expansion of file names
910
using Python's **glob()**, as shown further down in the following
893
911
code:
894
912
895
913
..  code-block:: java
@@ -996,19 +1014,21 @@ code:
996
1014
      }
997
1015
    }
998
1016
999
The last two examples show the extraction of Python tuples and lists into Java
1000
**List**\s, and Python dictionaries into Java **Map**\s. Both of these cases
1001
require more processing than is provided in the standard Jython library, so I
1002
have again created utilities in **net.mindview.pyton.PyUtil**: **toList()** to
1003
produce a **List** from a Python sequence, and **toMap()** to produce a **Map**
1004
from a Python dictionary. The **PyUtil** methods make it easier to take
1005
important data structures back and forth between Java and Python.
1017
The last two examples show the extraction of Python tuples and lists
1018
into Java **List**\s, and Python dictionaries into Java
1019
**Map**\s. Both of these cases require more processing than is
1020
provided in the standard Jython library, so I have again created
1021
utilities in **net.mindview.pyton.PyUtil**: **toList()** to produce a
1022
**List** from a Python sequence, and **toMap()** to produce a **Map**
1023
from a Python dictionary. The **PyUtil** methods make it easier to
1024
take important data structures back and forth between Java and Python.
1006
1025
1007
1026
Multiple Interpreters
1008
1027
--------------------------------------------------------------------------------
1009
1028
1010
It's also worth noting that you can have multiple **PythonInterpreter** objects
1011
in a program, and each one has its own name space:
1029
It's also worth noting that you can have multiple
1030
**PythonInterpreter** objects in a program, and each one has its own
1031
name space:
1012
1032
1013
1033
..  code-block:: java
1014
1034
@@ -1036,8 +1056,8 @@ in a program, and each one has its own n
1036
1056
    }
1037
1057
1038
1058
1039
When you run the program you'll see that the value of **a** is distinct within
1040
each **PythonInterpreter**.
1059
When you run the program you'll see that the value of **a** is
1060
distinct within each **PythonInterpreter**.
1041
1061
1042
1062
Creating Java classes with Jython
1043
1063
=======================================================================
@@ -1053,8 +1073,8 @@ code. This can produce very useful resul
1053
1073
treat the results as if they are native Java classes, albeit with
1054
1074
Python power under the hood.
1055
1075
1056
To produce Java classes from Python code, Jython comes with a compiler called
1057
**jythonc**.
1076
To produce Java classes from Python code, Jython comes with a compiler
1077
called **jythonc**.
1058
1078
1059
1079
The process of creating Python classes that will produce Java classes
1060
1080
is a bit more complex than when calling Java classes from Python,
@@ -1069,30 +1089,33 @@ standard location for the Python documen
1069
1089
    def returnArray(self):
1070
1090
        "@sig public java.lang.String[] returnArray()"
1071
1091
1072
The Python definition doesn't specify any return type, but the @sig string gives
1073
the full type information about what is being passed and returned. The
1074
**jythonc** compiler uses this information to generate the correct Java code.
1092
The Python definition doesn't specify any return type, but the @sig
1093
string gives the full type information about what is being passed and
1094
returned. The **jythonc** compiler uses this information to generate
1095
the correct Java code.
1075
1096
1076
There's one other set of rules you must follow in order to get a successful
1077
compilation: you must inherit from a Java class or interface in your Python
1078
class (you do not need to specify the **@sig** signature for methods defined in
1079
the superclass/interface). If you do not do this, you won't get your desired
1080
methods -- unfortunately, **jythonc** gives you no warnings or errors in this
1081
case, but you won't get what you want. If you don't see what's missing, it can
1082
be very frustrating.
1097
There's one other set of rules you must follow in order to get a
1098
successful compilation: you must inherit from a Java class or
1099
interface in your Python class (you do not need to specify the
1100
**@sig** signature for methods defined in the
1101
superclass/interface). If you do not do this, you won't get your
1102
desired methods -- unfortunately, **jythonc** gives you no warnings or
1103
errors in this case, but you won't get what you want. If you don't see
1104
what's missing, it can be very frustrating.
1083
1105
1084
In addition, you must import the appropriate java class and give the correct
1085
package specification.  In the example below, **java** is imported so you must
1086
inherit from **java.lang.Object**, but you could also say **from java.lang
1087
import Object** and then you'd just inherit from **Object** without the package
1088
specification. Unfortunately, you don't get any warnings or errors if you get
1089
this wrong, so you must be patient and keep trying.
1106
In addition, you must import the appropriate java class and give the
1107
correct package specification.  In the example below, **java** is
1108
imported so you must inherit from **java.lang.Object**, but you could
1109
also say **from java.lang import Object** and then you'd just inherit
1110
from **Object** without the package specification. Unfortunately, you
1111
don't get any warnings or errors if you get this wrong, so you must be
1112
patient and keep trying.
1090
1113
1091
Here is an example of a Python class created to produce a Java class. This also
1092
introduces the '**=T**' directive for the makefile builder tool, which specifies
1093
a different target than the one that is normally used by the tool. In this case,
1094
the Python file is used to build a Java **.class** file, so the class file is
1095
the desired target::
1114
Here is an example of a Python class created to produce a Java
1115
class. In this case, the Python file is used to build a Java
1116
**.class** file, so the class file is the desired target:
1117
1118
..  code-block:: python
1096
1119
1097
1120
    # Jython/PythonToJavaClass.py
1098
1121
    # A Python class converted into a Java class
@@ -1170,34 +1193,37 @@ the desired target::
1170
1193
            for x in m.keys():
1171
1194
                print(x, m[x])
1172
1195
1196
First note that **PythonToJavaClass** is inherited from
1197
**java.lang.Object**; if you don't do this you will quietly get a Java
1198
class without the right signatures. You are not required to inherit
1199
from **Object**; any other Java class will do.
1173
1200
1174
First note that **PythonToJavaClass** is inherited from **java.lang.Object**; if
1175
you don't do this you will quietly get a Java class without the right
1176
signatures. You are not required to inherit from **Object**; any other Java
1177
class will do.
1201
This class is designed to demonstrate different arguments and return
1202
values, to provide you with enough examples that you'll be able to
1203
easily create your own signature strings. The first three of these are
1204
fairly self-explanatory, but note the full qualification of the Java
1205
name in the signature string.
1178
1206
1179
This class is designed to demonstrate different  arguments and return values, to
1180
provide you with enough examples that you'll be able to easily create your own
1181
signature strings. The first three of these are fairly self-explanatory, but
1182
note the full qualification of the Java name in the signature string.
1207
In **returnArray()**, a Python array must be returned as a Java
1208
array. To do this, the Jython **array()** function (from the
1209
**jarray** module) must be used, along with the type of the class for
1210
the resulting array. Any time you need to return an array to Java, you
1211
must use **array()**, as seen in the methods **ints()** and
1212
**doubles()**.
1183
1213
1184
In **returnArray()**, a Python array must be returned as a Java array. To do
1185
this, the Jython **array()** function (from the **jarray** module) must be
1186
used, along with the type of the class for the resulting array. Any time you
1187
need to return an array to Java, you must use **array()**, as seen in the
1188
methods **ints()** and **doubles()**.
1214
The last methods show how to pass arguments in from Java. Basic types
1215
happen automatically as long as you specify them in the **@sig**
1216
string, but you must use objects and you cannot pass in primitives
1217
(that is, primitives must be ensconced in wrapper objects, such as
1218
**Integer**).
1189
1219
1190
The last methods show how to pass arguments in from Java. Basic types happen
1191
automatically as long as you specify them in the **@sig** string, but you must
1192
use objects and you cannot pass in primitives (that is, primitives must be
1193
ensconced in wrapper objects, such as **Integer**).
1194
1195
In **argIn3()**, you can see that a Java **List** is transparently converted to
1196
something that behaves just like a Python array, but is not a true array because
1197
you cannot take a slice from it. If you want a true Python array, then you must
1198
create and pass a **PyArray** as in **argIn4()**, where the slice is
1199
successful. Similarly, a Java **Map** must come in as a **PyDictionary** in
1200
order to be treated as a Python dictionary.
1220
In **argIn3()**, you can see that a Java **List** is transparently
1221
converted to something that behaves just like a Python array, but is
1222
not a true array because you cannot take a slice from it. If you want
1223
a true Python array, then you must create and pass a **PyArray** as in
1224
**argIn4()**, where the slice is successful. Similarly, a Java **Map**
1225
must come in as a **PyDictionary** in order to be treated as a Python
1226
dictionary.
1201
1227
1202
1228
Here is the Java program to exercise the Java classes produced by the
1203
1229
above Python code. You can't compile **TestPythonToJavaClass.java**
@@ -1253,31 +1279,33 @@ until **PythonToJavaClass.class** is ava
1253
1279
1254
1280
For Python support, you'll usually only need to import the classes in
1255
1281
**org.python.core**. Everything else in the above example is fairly
1256
straightforward, as **PythonToJavaClass** appears, from the Java side, to be
1257
just another Java class. **dumpClassInfo()** uses reflection to verify that the
1258
method signatures specified in **PythonToJavaClass.py** have come through
1259
properly.
1282
straightforward, as **PythonToJavaClass** appears, from the Java side,
1283
to be just another Java class. **dumpClassInfo()** uses reflection to
1284
verify that the method signatures specified in
1285
**PythonToJavaClass.py** have come through properly.
1260
1286
1261
1287
Building Java Classes from Python
1262
1288
--------------------------------------------------------------------------------
1263
1289
1264
Part of the trick of creating Java classes from Python code is the @sig
1265
information in the method documentation strings. But there's a second problem
1266
which stems from the fact that Python has no "package" keyword -- the Python
1267
equivalent of packages (modules) are implicitly created based on the file name.
1268
However, to bring the resulting class files into the Java program, **jythonc**
1269
must be given information about how to create the Java package for the Python
1270
code. This is done on the **jythonc** command line using the **--package** flag,
1271
followed by the package name you wish to produce (including the separation dots,
1272
just as you would give the package name using the **package** keyword in a Java
1273
program). This will put the resulting **.class** files in the appropriate
1274
subdirectory off of the current directory. Then you only need to import the
1275
package in your Java program, as shown above (you'll need '**.**' in your
1276
CLASSPATH in order to run it from the code directory).
1290
Part of the trick of creating Java classes from Python code is the
1291
@sig information in the method documentation strings. But there's a
1292
second problem which stems from the fact that Python has no "package"
1293
keyword -- the Python equivalent of packages (modules) are implicitly
1294
created based on the file name.  However, to bring the resulting class
1295
files into the Java program, **jythonc** must be given information
1296
about how to create the Java package for the Python code. This is done
1297
on the **jythonc** command line using the **--package** flag, followed
1298
by the package name you wish to produce (including the separation
1299
dots, just as you would give the package name using the **package**
1300
keyword in a Java program). This will put the resulting **.class**
1301
files in the appropriate subdirectory off of the current
1302
directory. Then you only need to import the package in your Java
1303
program, as shown above (you'll need '**.**' in your CLASSPATH in
1304
order to run it from the code directory).
1277
1305
1278
Here are the **make** dependency rules that I used to build the above example
1279
(the backslashes at the ends of the lines are understood by **make** to be line
1280
continuations)::
1306
Here are the **make** dependency rules that I used to build the above
1307
example (the backslashes at the ends of the lines are understood by
1308
**make** to be line continuations)::
1281
1309
1282
1310
    TestPythonToJavaClass.class: \\
1283
1311
            TestPythonToJavaClass.java \\
@@ -1290,25 +1318,27 @@ continuations)::
1290
1318
        PythonToJavaClass.py
1291
1319
1292
1320
The first target, **TestPythonToJavaClass.class**, depends on both
1293
**TestPythonToJavaClass.java** and the **PythonToJavaClass.class**, which is the
1294
Python code that's converted to a class file. This latter, in turn, depends on
1295
the Python source code. Note that it's important that the directory where the
1296
target lives be specified, so that the makefile will create the Java program
1297
with the minimum necessary amount of rebuilding.
1321
**TestPythonToJavaClass.java** and the **PythonToJavaClass.class**,
1322
which is the Python code that's converted to a class file. This
1323
latter, in turn, depends on the Python source code. Note that it's
1324
important that the directory where the target lives be specified, so
1325
that the makefile will create the Java program with the minimum
1326
necessary amount of rebuilding.
1298
1327
1299
1328
Summary
1300
1329
=======================================================================
1301
1330
1302
This chapter has arguably gone much deeper into Jython than required to use the
1303
interpreter design pattern. Indeed, once you decide that you need to use
1304
interpreter and that you're not going to get lost inventing your own language,
1305
the solution of installing Jython is quite simple, and you can at least get
1306
started by following the **GreenHouseController** example.
1331
This chapter has arguably gone much deeper into Jython than required
1332
to use the interpreter design pattern. Indeed, once you decide that
1333
you need to use interpreter and that you're not going to get lost
1334
inventing your own language, the solution of installing Jython is
1335
quite simple, and you can at least get started by following the
1336
**GreenHouseController** example.
1307
1337
1308
Of course, that example is often too simple and you may need something more
1309
sophisticated, often requiring more interesting data to be passed back and
1310
forth. When I encountered the limited documentation, I felt it necessary to come
1311
up with a more thorough examination of Jython.
1338
Of course, that example is often too simple and you may need something
1339
more sophisticated, often requiring more interesting data to be passed
1340
back and forth. When I encountered the limited documentation, I felt
1341
it necessary to come up with a more thorough examination of Jython.
1312
1342
1313
1343
In the process, note that there could be another equally powerful
1314
1344
design pattern lurking in here, which could perhaps be called
@@ -1319,57 +1349,63 @@ much faster than with either language by
1319
1349
to bridge across languages, and at the same time bridging between
1320
1350
computers and operating systems.
1321
1351
1322
To me, Python and Java present a very potent combination for program development
1323
because of Java's architecture and tool set, and Python's extremely rapid
1324
development (generally considered to be 5-10 times faster than C++ or Java).
1325
Python is usually slower, however, but even if you end up re-coding parts of
1326
your program for speed, the initial fast development will allow you to more
1327
quickly flesh out the system and uncover and solve the critical sections. And
1328
often, the execution speed of Python is not a problem -- in those cases it's an
1329
even bigger win. A number of commercial products already use Java and Jython,
1330
and because of the terrific productivity leverage I expect to see this happen
1331
more in the future.
1352
To me, Python and Java present a very potent combination for program
1353
development because of Java's architecture and tool set, and Python's
1354
extremely rapid development (generally considered to be 5-10 times
1355
faster than C++ or Java).  Python is usually slower, however, but even
1356
if you end up re-coding parts of your program for speed, the initial
1357
fast development will allow you to more quickly flesh out the system
1358
and uncover and solve the critical sections. And often, the execution
1359
speed of Python is not a problem -- in those cases it's an even bigger
1360
win. A number of commercial products already use Java and Jython, and
1361
because of the terrific productivity leverage I expect to see this
1362
happen more in the future.
1332
1363
1333
1364
Exercises
1334
1365
=======================================================================
1335
1366
1336
#.  Modify **GreenHouseLanguage.py** so that it checks the times for the events
1337
    and runs those events at the appropriate times.
1367
#.  Modify **GreenHouseLanguage.py** so that it checks the times for
1368
    the events and runs those events at the appropriate times.
1338
1369
1339
#.  Modify **GreenHouseLanguage.py** so that it calls a function for **action**
1340
    instead of just printing a string.
1370
#.  Modify **GreenHouseLanguage.py** so that it calls a function for
1371
    **action** instead of just printing a string.
1341
1372
1342
#.  Create a Swing application with a **JTextField** (where the user will enter
1343
    commands) and a **JTextArea** (where the command results will be displayed).
1344
    Connect to a **PythonInterpreter** object so that the output will be sent to
1345
    the **JTextArea** (which should scroll). You'll need to locate the
1346
    **PythonInterpreter** command that redirects the output to a Java stream.
1373
#.  Create a Swing application with a **JTextField** (where the user
1374
    will enter commands) and a **JTextArea** (where the command
1375
    results will be displayed).  Connect to a **PythonInterpreter**
1376
    object so that the output will be sent to the **JTextArea** (which
1377
    should scroll). You'll need to locate the **PythonInterpreter**
1378
    command that redirects the output to a Java stream.
1347
1379
1348
#.  Modify **GreenHouseLanguage.py** to add a master controller class (instead
1349
    of the static array inside **Event**) and provide a **run()** method for
1350
    each of the subclasses. Each **run()** should create and use an object from
1351
    the standard Java library during its execution. Modify
1352
    **GreenHouseController.java** to use this new class.
1380
#.  Modify **GreenHouseLanguage.py** to add a master controller class
1381
    (instead of the static array inside **Event**) and provide a
1382
    **run()** method for each of the subclasses. Each **run()** should
1383
    create and use an object from the standard Java library during its
1384
    execution. Modify **GreenHouseController.java** to use this new
1385
    class.
1353
1386
1354
#.  Modify the resulting **GreenHouseLanguage.py** from exercise two to produce
1355
    Java classes (add the @sig documentation strings to produce the correct Java
1356
    signatures, and create a makefile to build the Java **.class** files). Write
1357
    a Java program that uses these classes.
1387
#.  Modify the resulting **GreenHouseLanguage.py** from exercise two
1388
    to produce Java classes (add the @sig documentation strings to
1389
    produce the correct Java signatures, and create a makefile to
1390
    build the Java **.class** files). Write a Java program that uses
1391
    these classes.
1358
1392
1359
#.  Modify **GreenHouseLanguage.py** so that the subclasses of **Event** are not
1360
    discrete classes, but are instead *generated* by a single function which creates
1361
    the class and the associated string dynamically.
1393
#.  Modify **GreenHouseLanguage.py** so that the subclasses of
1394
    **Event** are not discrete classes, but are instead *generated* by
1395
    a single function which creates the class and the associated
1396
    string dynamically.
1362
1397
1363
1398
.. rubric:: Footnotes
1364
1399
1365
.. [#]  The original version of this was called *JPython*\, but the project
1366
        changed and the name was changed to emphasize the distinctness of the new
1367
        version.
1400
.. [#] 	The original version of this was called *JPython*\, but the
1401
        project changed and the name was changed to emphasize the
1402
        distinctness of the new version.
1368
1403
1369
.. [#]  Changing the registry setting **python.security.respectJavaAccessibility
1370
        = true** to **false** makes testing even more powerful because it allows
1371
        the test script to use *all* methods, even protected and package-
1372
        private.
1404
.. [#]  Changing the registry setting
1405
        **python.security.respectJavaAccessibility = true** to
1406
        **false** makes testing even more powerful because it allows
1407
        the test script to use *all* methods, even protected and
1408
        package- private.
1373
1409
1374
1410
1375
1411

Up to file-list html/genindex.html:

198
198
    </div>
199
199
    <div class="footer">
200
200
      © Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
201
      Last updated on Dec 30, 2008.
201
      Last updated on Dec 31, 2008.
202
202
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.
203
203
    </div>
204
204
  </body>

Up to file-list html/index.html:

160
160
</ul>
161
161
<ul>
162
162
<li class="toctree-l1"><a class="reference external" href="Jython.html">Jython</a><ul>
163
<li class="toctree-l2"><a class="reference external" href="Jython.html#interpreter-motivation">Interpreter Motivation</a></li>
164
163
<li class="toctree-l2"><a class="reference external" href="Jython.html#installation">Installation</a><ul>
165
164
<li class="toctree-l3"><a class="reference external" href="Jython.html#getting-the-trunk">Getting the Trunk</a></li>
166
165
</ul>
167
166
</li>
168
167
<li class="toctree-l2"><a class="reference external" href="Jython.html#scripting">Scripting</a></li>
169
<li class="toctree-l2"><a class="reference external" href="Jython.html#creating-a-language">Creating a Language</a></li>
168
<li class="toctree-l2"><a class="reference external" href="Jython.html#interpreter-motivation">Interpreter Motivation</a><ul>
169
<li class="toctree-l3"><a class="reference external" href="Jython.html#creating-a-language">Creating a Language</a></li>
170
</ul>
171
</li>
170
172
<li class="toctree-l2"><a class="reference external" href="Jython.html#using-java-libraries">Using Java libraries</a><ul>
171
173
<li class="toctree-l3"><a class="reference external" href="Jython.html#inheriting-from-java-library-classes">Inheriting from Java library Classes</a></li>
172
174
</ul>
427
429
    </div>
428
430
    <div class="footer">
429
431
      © Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
430
      Last updated on Dec 30, 2008.
432
      Last updated on Dec 31, 2008.
431
433
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.
432
434
    </div>
433
435
  </body>

Up to file-list html/search.html:

91
91
  
92
92
    <div class="footer">
93
93
      © Copyright 2008, Creative Commons Attribution-Share Alike 3.0.
94
      Last updated on Dec 30, 2008.
94
      Last updated on Dec 31, 2008.
95
95
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.
96
96
    </div>
97
97
  <script type="text/javascript" src="searchindex.js"></script>

Up to file-list html/searchindex.js:

1
Search.setIndex({desctypes:{},terms:{defaultcloseoper:10,orthogon:20,yellow:28,four:[13,35,12],secondli:19,prefix:28,sleep:[35,28],dirnam:[1,6],"00798f9c":27,browse_thread:7,gladiolu:31,evalscissor:22,whose:[16,21,11,22,28],selen:7,concret:[21,1,4],swap:[34,28],under:[20,10,11,1,12,2,16,34,7],testabl:1,worth:[21,10,4],lure:12,everi:[20,32,10,1,12,2,4,16,21,28,14,19],risk:29,inventfeatur:31,matchobj:6,rise:20,lurk:10,voic:[2,13,1],penchant:32,decorator_without_argu:14,govern:12,affect:[21,28],rare:20,disturb:[21,4],nestedshapefactori:4,metaclass:[27,14],decorator_with_argu:14,correct:[10,21,12],"__templatemethod":0,getdeclaredmethod:1,technolog:[13,1],verif:1,unpredictableperson:12,cappuccinowhip:19,c02:1,categori:[20,14,28],cmp:12,storag:27,"10f":21,direct:[20,9,10,12,4,14,35],sourceforg:[10,28],nail:21,second:[32,10,11,28,27,22,16,21,34,14],classcastexcept:16,"__finditem__":10,even:[10,11,1,13,27,32,18,34,7,21,14,19],hide:[20,21,36],createshap:4,canvasheight:35,item1:22,weren:27,shallowai:11,firstdigit:12,"new":[20,32,10,0,1,12,2,3,15,4,22,16,13,11,6,31,7,21,8,19,35],net:[10,1,28,2,13,7],ever:[16,21,22],succumb:1,liberti:36,told:4,getsiz:28,widget:28,behavior:[20,10,11,28,12,27,22,16,21,36,14,35],never:[2,27,10,21,1],here:[1,2,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,21,22,27,28,30,32,35,36],"__hash__":12,debugg:7,gridlayout:28,path:[21,1,12,10,6,7,28],cardboard:21,interpret:[20,9,10,11,21],dry:19,sweeet:7,howev:[20,32,10,11,1,12,13,31,28,4,16,21,34,5,35,36,7,27,14,19],haschang:[28,12],credit:[13,9],errmsg:1,studi:[20,21,1,28,4],readlinesetup:10,portabl:[10,4],tremend:10,golden:20,argin4:10,"_test":6,brought:[7,32,10],substr:21,unix:30,ratsandmaz:35,wateron:10,total:[10,21,12],unit:[9,10,1],getchar:10,plot:28,redon:13,describ:[20,32,10,1,12,2,31,21,16,34,5,7,19],would:[32,10,0,1,12,2,28,4,16,21,11,17,27,14,19],quickpython:32,suit:1,call:[20,32,10,0,1,12,31,28,4,22,16,21,11,6,36,7,27,14,34],typo:13,recommend:21,type:[20,9,10,11,1,12,32,31,28,4,22,16,21,36,7,27,19],until:[20,10,11,12,31,21,32,6,18,14],looni:11,relat:[20,34],notic:[10,1,28,31,22,4,32,21,14],hurt:28,warn:[20,10,8,21],glass:21,flowervisitor:31,moin:14,hole:1,hold:[10,11,12,13,21,16],unpack:[10,21],must:[10,11,1,12,2,31,28,4,22,32,21,5,35,36,7,27,14,19],join:[10,6],err:[21,1],setup:[7,1,4],work:[20,9,10,21,1,28,32,2,8,4,22,16,13,34,6,7,27,14,19,18],worm:31,contentpan:10,root:[21,1],overrid:[21,0,1,28,12,32,7],walk_comprehens:10,give:[20,10,1,30,2,21,32,13,7,14,35],digit:12,indic:[9,10,29,12,21,4,32,28,14],doublevalu:21,setvis:[10,35,28],unavail:12,unassign:7,david:[20,32],addtobin:21,end:[20,10,11,28,2,22,32,13,21,8,35],quot:32,ordinari:[21,10,1,28,4],classifi:[20,9],revisit:[21,4],how:[20,32,10,11,1,28,2,31,15,4,22,16,13,7,27,21,19],hot:19,disappear:[18,35],env:1,answer:[7,21,1,22],verifi:[10,1],changeinterfac:36,perspect:[20,21],"void":[10,1],updat:[29,28,6,7,8,35],my_new:27,recogn:[],lai:1,mess:2,coffeeshop:19,after:[20,10,11,1,12,8,27,32,21,35,7,14,19],implementation1:34,lump:34,implementation2:34,diagram:[9,21,12,13,34,7,8,19],befor:[20,32,10,11,1,12,2,21,16,28,14,19],wrong:[21,10,1],beauti:[21,34],law:20,parallel:[20,3],demonstr:[10,0,1,28,12,31,22,32,34],beanmeup:19,chere:7,profess:17,attempt:[20,21,1],third:21,classmethod:27,revolv:20,exclud:1,wink:0,maintain:[20,21,11,12,13,22,35,14,19],environ:[7,31,21,4,30],incorpor:[10,11,14,1],enter:[10,14,28,12,35],lambda:10,someplac:7,order:[32,10,0,28,12,2,4,16,21,11,5,7,8,19,34],oper:[20,9,10,11,32,12,31,15,4,22,16,21,7,14],composit:20,os_walk_comprehens:6,over:[20,32,10,11,1,2,21,16,14],fall:[14,1,30],orang:28,becaus:[20,32,10,21,1,12,2,31,27,16,13,34,36,7,28,14,18],paperscissorsrock:[31,22],flexibl:[20,9,10,11,12,22,32,21,37,19],vari:[20,11],fit:[20,21,11,1,28,2,34],fix:[27,28,29,13,31,21,7,8,19],avocado:19,"__class__":[31,10,11,22,19],bytecod:10,better:[20,10,11,1,12,2,21,13,28,14],imp:[16,34],blemang:32,comprehens:[9,10,6],hidden:[32,21,0,34],schmidt:21,easier:[20,10,1,12,31,5,7,28,14],glassbin:21,them:[20,32,10,11,1,28,2,31,22,16,13,35,6,7,21,14,19,17],thei:[20,32,10,11,1,12,2,31,27,16,13,6,36,28,21,14,19],proce:7,safe:[16,9,10,14],stringformat:32,"break":[21,1,29,19,35,6],promis:21,setvalu:21,"instanceof":21,choic:[21,11,28,2,31,4,22,13,35,7,19],grammat:2,alex:27,brough:[],getvalu:[10,21,12],closeobserv:28,each:[20,9,10,0,1,12,31,28,4,22,32,21,11,35,6,27,8,19,34],debug:[10,8,29],side:[7,13,10,21,1],mean:[20,32,10,11,1,12,13,31,21,16,34,28,14,19],prohibit:21,setdefaultcloseoper:[10,28],nochang:12,enorm:14,arduou:19,taught:11,makecharact:4,receptacl:21,collector:10,whip:19,goe:[13,32,21,19],langug:10,gof:[20,11,34],content:21,rewrit:[10,2,8,21,16,13,34,36,7,14,19],dsl:10,vector:[20,21,35,12],adapt:[7,9,21,36],reader:[9,1,13,16,32,5,18],got:[13,1,36],washer:12,forth:10,linear:20,barrier:20,written:[32,11,1,28],situat:[32,27,10,21,1],free:[7,13,20,12],standard:[20,10,11,1,28,32,14],ncpu:30,println:[21,10,1],mousemovegener:12,quickinstal:7,sheet:[7,1],kit:10,acrobat:7,uiuc:21,puzzl:4,angl:20,openssh:7,mvc:28,isn:[20,10,0,28,2,21,32,34],subtl:[20,21],onto:20,bite:1,rang:[10,0,28,31,4,22,32],isassignablefrom:1,gradi:21,hoop:14,independ:[20,21,28],wast:[32,4,28],restrict:[2,10,14,27,28],"__tojava__":10,unlik:[32,21,11,1],alreadi:[20,10,11,1,28,2,21,16,7,35],wrapper:[10,21],wasn:21,getmemb:6,thick:4,agre:32,primari:[3,21,11,1,31],hood:10,brillig:10,vendingmachinetest:12,rewritten:[13,18],"__implement":34,spinach:19,top:19,evolut:[20,21],cardboardbin:21,rsrc:28,gnureadlin:10,master:[10,21,12],too:[20,10,1,13,21,33,18,14,19],similarli:10,consol:[10,1],tool:[9,10,11,1,12,2,4,13,7,28,21,8],propon:21,getcontentpan:28,somewhat:2,technic:13,trek:27,silli:21,target:[10,28],keyword:[32,10,4,28],provid:[20,32,10,0,1,12,28,4,16,21,11,36,7,27,14,19,34],"__onlyon":27,tree:[10,1],hors:32,prong:21,project:[20,9,10,1,2,31,21,13,17,7,8,35],matter:[13,20,21,11,4],pressur:1,foamedmilk:19,fashion:[32,21,14],mind:[13,27,1,6],mine:7,raw:32,aforement:20,cohes:[20,21],"__main__":[27,1,28,10,32,6],seen:[20,32,10,11,28,12,2,4,16,34,14],seem:[20,10,1,12,14,4,32,21,34,8],seek:[21,12],seminar:2,innerclass:10,realm:[16,20],respectjavaaccess:10,terrif:10,latter:[20,10],cope:21,thorough:10,alreadyopen:28,staticinnerclass:10,client:[21,0,1,12,2,34,36],alldecor:19,thoroughli:2,wherebi:12,simplifi:[7,27,10,4],shall:[10,11,1],bruce:7,glob:[10,1],object:[20,9,10,11,1,12,32,8,28,4,22,16,21,34,5,35,36,31,27,14,19],deleg:[27,34,21],regular:[32,10,1,19],letter:0,phase:[20,21,14],coin:11,brien:21,tradit:20,simplic:[20,31,10,12,32],don:[20,9,10,21,28,2,3,4,22,32,13,33,34,36,7,14,18],simplif:10,pythoninterpreterset:10,doc:7,flow:[13,10],doe:[20,10,11,1,12,8,28,4,32,21,0,27,14,29,34],bash_profil:7,dummi:11,declar:[32,1],wildcard:10,itemslot:12,notion:34,dot:10,marvel:32,has_kei:[21,4,12,30],endear:10,visitor:[20,9,21,1,28,31],"__str__":[31,27,11,22,12],random:[20,21,28,31,4,22],syntax:[10,1,27,32,21,5,14],"2008v1":7,involv:[20,27,15,21,16,7],despit:21,layout:[2,13,10],acquir:28,menu:[7,15,4,19],explain:[34,14,1,4],configur:[9,10,28,12,13,22,21,7,37],restaur:19,sugar:14,theme:11,busi:31,"__call__":[27,11,14],priveledg:[],oct:10,edict:31,cappuccino:19,vener:7,stop:[21,1],next:[10,11,1,12,4,16,21,27,35],on_mouseup:28,report:[7,1,35],rosettacod:11,bat:10,bar:[13,3,27],isopen:28,emb:[32,10],baz:3,shape:[21,4],method:[20,9,10,0,1,12,31,28,4,22,32,21,11,6,36,27,14,19,34],twice:[1,28],bad:[13,4],steam:19,fair:11,decoratortalk:14,elimin:[10,21],mandatori:20,result:[20,32,10,11,1,28,21,16,6,14,19,35],respons:[9,21,0,12,32,11,35,19],fail:[21,10,14,1,12],themselv:[20,32,28],bee:[31,34,28],hammer:21,best:[20,10,2,32,13,7,14],brazil:2,awar:[21,10,4,28],said:2,alsum:21,databas:27,hgrc:7,red3d:35,discoveri:[20,21],figur:[2,13,10,21,30],emptor:18,simplest:[20,27,10,1,28],awai:[20,21,19,12],getkei:10,approach:[20,9,10,28,12,31,4,16,21,36,7,27,14,19],attribut:[2,14,10,5,20],accord:[16,21,1],extend:[16,31,21,1,4],xrang:10,weak:32,extens:[7,13,10,21],lazi:[27,34,12],preprocessor:14,backgroundcolor:28,rtti:[9,21],aparat:21,protect:[10,34,1,28],accident:[20,21],expos:[21,36],ill:21,pitt:14,against:[31,10,14,21],logic:[20,28,19],countri:11,com:[20,10,1,12,13,21,16,7,14,35],con:19,compromis:[9,19],kwd:27,notifyobserv:28,elf:31,excess:12,coconut:32,"2nd":10,diff:7,guid:[7,9],assum:[7,32,27,21],panel:28,duplic:[20,6],light:10,testsynchron:28,three:[20,10,12,31,14,19],been:[20,10,21,28,12,2,27,32,13,34,18,14],chrysanthemum:31,much:[20,10,21,1,28,2,3,4,32,13,31,7,14,18],interest:[20,10,1,28,2,27,21,14],basic:[20,9,10,1,12,2,4,32,16,21,34,36,28,14,19],"__doc__":6,"__len__":10,quickli:[10,12],life:28,rather:[32,10,1,28,30,13,31,4,16,21,34,36,14,19],deeper:[21,10,4],getval:10,xxx:30,isfunct:6,dave:16,alreadyclos:28,bookstor:2,ugli:[21,36],exception:[32,10],ident:[27,36,21,12],occam:20,gnu:1,servic:[2,13],properti:10,commerci:[13,10],air:[4,12],employ:2,calcul:[11,28],aid:32,vagu:20,dizzi:20,enlev:20,seconddigit:12,player:28,kwarg:[5,6],indent:[13,32,6],tediou:[10,28],sever:[21,10,4,12],valgen:10,quand:20,perform:[20,10,11,1,12,31,4,22,21,0,28,14,19],suggest:[20,27,1,13,21,32,7],make:[1,2,4,5,6,7,8,9,10,11,12,13,14,17,19,20,21,22,27,29,28,31,32,34],transpar:[10,1,19],complex:[9,10,11,1,28,4,6,14],descend:1,tackl:21,complet:[20,10,1,12,21,34,7,28,14,35],inheritor:28,blue:28,listperform:37,hand:[20,32,27,11,28,13,4,16,21,14],fairli:[20,21,1,28,10,22],nix:10,rais:[2,21,12],garlic:19,refin:[10,8,21],techniqu:[27,3,21,4,16,31],qualif:10,jframe:[10,28],kept:[2,1],thu:[20,32,10,11,1,12,4,22,16,21,0,14,19],getbyt:35,inherit:[20,9,10,11,1,12,28,4,32,21,0,27,19],runtimeexcept:[16,12],academia:11,shortli:[32,1],greatest:[20,21],thi:[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,18,19,20,21,22,27,28,29,31,32,33,34,35,36],programm:[20,9,10,0,1,12,2,27,32,34,36,14],everyth:[10,28,30,2,21,32,13,18,14],isomorph:20,left:[20,21,28,13,31,15,6,7],agon:2,identifi:[7,32,10,4],setcolor:[35,28],just:[20,10,11,1,12,30,2,28,4,22,32,13,34,5,6,7,27,21,14,19,18],"__dict__":[27,5,6,28],kdiff3:7,yet:[32,10,1,28,13,27,16,21,6,18,35],languag:[20,9,10,11,1,12,3,4,32,21,33,6,14,29],previous:[21,4],easi:[20,10,1,22,32,21,7,19],had:[20,32,10,11,1,12,2,31,21,16,35,14,19],keyset:[10,21],spread:[4,22],prison:35,falter:1,els:[20,10,1,12,30,27,32,21,6,7,35],functionobject:11,explanatori:10,gave:[2,21],applic:[20,9,10,0,12,4,34,7,14],larman:36,mayb:[13,8,1],ajout:20,background:28,elabor:21,shadow:20,unten:14,readlineconsol:10,apart:20,maxval:10,specif:[20,10,11,1,12,4,16,21,34,7,28,8],arbitrari:[32,21],nudg:0,hunt:[21,35,28],manual:[21,22],doubledispatch:21,tymciurak:7,night:[2,10],ocbox:28,unnecessari:[10,34,4,12],singletonpattern:27,underli:20,www:[20,32,10,11,1,12,21,16,7,28,14,35],right:[20,10,28,13,2,21,32,18,6,7],old:21,deal:[21,10,22,36],printf:32,interp:10,somehow:[10,34,21],percentag:2,intern:[16,21,1,4],borg:27,unless:[2,34,1,6],indirect:21,successfulli:[7,21,1],atteint:20,txt:[35,12],clash:21,bottom:[32,11],subclass:[9,10,12,4,21,19],suffici:10,condit:[9,11,1,12,4,32,35],foo:[13,3,10,14,27],core:[7,32,10],sensibl:[4,22],steamedmilk:19,confer:[2,13,21],promot:[2,21],repositori:2,pylist:10,post:[7,14],"super":[27,28],meyer:35,chapter:[32,10,11,1,2,8,21,16,13,33,35,37,14,19],unpackag:10,alexand:16,eat:31,getparametertyp:1,slightli:[9,12,1,28,5,14],py2float:10,surround:[32,21,35,28],unfortun:10,commit:[7,8],produc:[20,10,21,1,12,2,31,4,22,16,13,36,14],makeobstacl:4,dilemma:[31,21],thermostat:10,javac:10,curiou:18,basenam:6,"float":10,encod:22,bound:[2,31,10,21],mocha:19,down:[10,11,1,28,4,35,19],creativ:[2,21,17],weightvisitor:21,bizarr:14,cappuccinodecafwhip:19,wrap:[10,11,28,27,16,21,14,19],opportun:21,clearchang:28,javax:10,testdumpclassinfo:10,east:35,accordingli:13,wai:[20,10,11,1,12,30,2,31,28,4,32,13,34,5,36,7,27,21,14,19,29],frustrat:10,support:[9,10,1,12,2,3,4,32,21,17,7,28],iter:[20,9,10,1,12,4,32,16,21,26],why:[20,21,14],avail:[20,10,11,1,2,21,32],stuck:[10,1],reli:[16,21,5],editor:[7,13],fork:7,head:[20,11],medium:20,autonom:35,form:[20,9,21,1,28,2,15,4,16,32],offer:19,forc:[20,32,10,1,28,2,4,16,34,6],forg:1,heat:12,hear:1,dead:35,heap:[21,34],hashtabl:[],"true":[21,1,12,10,4,32],analyst:21,"6dd415847e5cbf7c":7,entryexit:14,pragu:21,setsuccess:11,maximum:[20,32],tell:[10,11,1,12,4,32,21,7,35],singletonmetaclass:27,absenc:1,fundament:[11,20,0,1,32],trim:21,classif:20,featur:[20,10,1,2,15,21,32,33,7,14],setxi:35,semicolon:32,classic:[21,12],howdi:10,stronger:32,"abstract":[20,9,21,4,36],flaw:1,sale:2,exist:[16,21,0,4,6],door:12,mold:[21,36],trip:2,assembl:19,inde:[27,10,21,14,1],surpris:[32,14],excel:16,refactor:[9,21,1,29],tij:37,test:[20,9,10,11,1,12,21,18,6,7,28,8],tie:20,presum:[21,4],smell:12,realiti:10,getsizetupl:28,notif:[20,28],intend:[2,10,1],felt:10,intent:[16,20,31],consid:[20,9,10,11,1,22,21,34,35,14,19],bitbucket:[7,9,8,29],receiv:[10,14,28],longer:[10,13,21,32,14,19],furthermor:11,intimaci:21,ignor:[21,27,1],inexpens:21,time:[20,32,10,0,1,12,2,28,4,16,13,11,35,27,21,14,19],push:7,backward:[35,29],osx:[7,30],concept:[20,9,10,0,11],chain:[9,11,12],nextstat:12,skip:1,consum:[10,5,19],focus:4,invent:[10,34],cafelattedecaf:19,objcount:1,milk:19,row:[28,12],decid:[21,12,28,31,10,4,32,34,19],depend:[20,21,29,12,10,4,28,8],decim:32,intermedi:2,certainli:[20,21,28,12,10,4,34,19],decis:[13,16,35,32],jvm:10,mainloop:28,jtextarea:10,isinst:[16,30],"__metaclass__":27,sourc:[20,10,1,12,2,21,13,7,28,35],string:[9,10,11,1,12,4,32,21,28,35],brazillian:2,onlyon:27,"fa\u00e7ad":[9,36],broadli:21,word:[11,1,12,0,36,14],exact:[21,4,12,22],valuabl:21,level:[20,21,1,28,4,32,6,14],did:[32,10,6],die:35,gui:[0,4,28],evalpap:22,vein:14,item:[28,10,4,12,22],team:[2,7,29,9],quick:[9,10,1,32,7,19],round:34,dir:[10,1,6],dict:[27,10,5,6],prevent:[9,21,1,28,4,34],plaincap:19,paintcompon:28,htm:35,compens:20,sign:[7,10,8],bondag:14,cost:[20,19,12],cafelattewetwhip:19,patient:10,corba:10,appear:[20,10,11,1,12,13,8,28,4,32,21,27,14,29],filler:21,scaffold:4,restfil:[10,6],current:[20,32,10,1,12,21,16,8,35],suspect:4,newalgorithm:11,shapefact2:4,deriv:[21,12,1,28,10,4,32,34],cappuccinodri:19,gener:[1,2,4,6,7,8,9,10,11,12,14,16,35,20,27,22,26,21,29,28,31,32,34,36],satisfi:[20,21,11,12,34],modif:[21,14,19],chainlink:11,address:34,along:[20,32,10,1,12,21,16,34],viabl:20,teacher:17,wait:[28,10,21,12],box:[9,10,1,28,4],messengeridiom:5,nextb:12,alti:28,shift:6,queue:11,behav:[10,14,21,12],extrem:[7,21,10,14,1],commonli:[10,21],trashtyp:21,semant:[32,1],regardless:[21,34],mazegen:35,extra:[32,28,21,1,19],activ:[13,31,21,4],modul:[32,3,10,14,28],prefer:13,toarrai:10,visibl:10,codemark:6,instal:[9,10,1,28,21,7],forefront:1,gsum:21,anounc:7,red:[35,28],newslett:20,prove:[21,14],univers:[20,4],visit:[31,10,21],recycleap:21,subvers:10,everybodi:28,live:10,handler:28,msg:32,scope:32,checkout:[7,8],testid:1,trustworthi:6,testpyutil:10,afford:11,peopl:[20,21,1,29,2,31,32,13,17,7,14],claus:[32,28,4,12],clue:21,visual:[7,9,28,13],appendix:2,rigid:10,oop:[20,21,1,28],examin:[10,21],obj:[16,32],jlabel:10,effort:[9,10,11,1,2,21,17],easiest:[7,9,10,31],fly:31,graphic:[35,1,28,4],prepar:14,dmitri:27,battl:[31,4],focu:[13,3,21],addel:35,flowlayout:10,problemsolv:11,can:[1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,27,28,31,32,34,35,36],purpos:[20,21,11,4],problemat:16,claim:11,encapsul:[20,9,21,11,12,4],stream:10,predict:14,wrapped_f:14,statet:12,backslash:[32,10],topic:[2,32,27],heard:21,chih:27,abort:[1,6],proxydemo:34,recycl:[9,21],simul:[20,9,21],occur:[20,21,11,1,12,13,4,22,28],pink:28,alwai:[20,27,0,1,29,10,32,21,8],killanddismemb:4,variou:[20,10,11,1,12,31,4,22,21,0,19],distinctli:12,ping:10,write:[20,9,10,0,1,12,2,4,32,16,13,11,6,28,21,34],anyon:[2,35],pure:[10,12],"0x00798900":27,parameter:21,ensconc:10,map:[10,12,31,21,32,35],product:[13,32,10,1],modal:10,book:[20,9,27,0,1,2,8,4,32,13,11,17,36,31,7,21,14,35,18],max:28,thermostatdai:10,spot:[13,4],usabl:12,wantmor:12,inputb:12,inputc:12,mac:7,inputa:12,mymethod:28,aop:14,mai:[20,32,10,11,1,12,2,28,4,16,13,33,35,7,27,21,19],underscor:[13,32,27],data:[9,10,11,28,12,4,32,16,21,5,27],grow:33,newlin:32,my_login:7,practic:32,johnson:20,secur:[10,14],explicit:[20,11,14,22],cafelattewhip:19,inform:[10,11,1,12,30,8,28,4,22,32,21,5,7,27,14,35],"switch":[21,11,35,34],preced:19,combin:[9,10,11,28,2,22,19],gamma:20,callabl:[14,28],talk:[7,20,10,21],vike:32,extractor:[8,1],dojo:17,mouseact:12,countobserv:28,greenhouselanguag:10,brain:[32,11],lst:10,codemanag:6,still:[20,10,21,28,12,2,4,32,13,6,7,8],skeleton:34,stringlist:21,dynam:[20,9,10,11,28,31,4,22,32,21,34,14,19],rosetta:17,group:[20,21,11,28,2,31,32,6,7,35,17],thank:[9,29],polici:0,jim:[21,11],platform:[9,10,30],window:[9,10,30,13,15,7,8],curli:32,borgsingleton:27,jtextfield:10,ddtrash:21,non:[20,10,1,2,21,32],dispens:12,halt:1,halv:32,sysconf_nam:30,alist:7,initi:[20,10,0,28,12,4,21,34,7,27,8,35],sorter:21,underneath:7,typedbinmemb:21,pyinteg:10,aesthet:21,therebi:1,half:34,javaclassinpython:10,now:[20,10,1,12,31,4,21,35,7,14,29],discuss:[20,21,35],introduct:[2,7,14,32,9],term:[20,21,11,1,12,34,36,14],name:[20,10,0,1,12,13,8,28,4,22,32,21,34,5,6,7,27,14,19],ppr:21,getweapon:31,didn:[20,32,8,1],oliv:19,phyast:14,separ:[20,10,0,1,12,31,4,32,21,11,7,28,34],rock:22,cafemochadecafwhip:19,pizza:19,jmap:10,compil:[20,10,11,1,28,21,32,34,6,18,14],domain:10,replac:[10,11,1,13,31,32,14],individu:[7,21,35,19],arg3:14,continu:[21,1,12,10,32,6],ensur:[7,20,34,1,6],parsetrash:21,significantli:14,begun:20,year:[16,20,21,1],happen:[20,10,21,1,12,2,4,13,28,14,19],dispos:10,troll:31,shown:[20,21,11,31,10,4,32,19],accomplish:[21,28,10,32,34,36,27],cafemochawhip:19,"3rd":[16,19],space:[21,13,10,32,34,6,35],profit:[2,10],antoin:20,profil:10,internet:[1,35],returnstr:10,factori:[20,9,21,12,4,36],earlier:21,"goto":21,occupi:32,getcwd:1,argu:[13,3,16,14,20],argv:6,lab:21,org:[10,11,1,29,14,32,7,28,8],"byte":[10,35],care:[13,32,21,4],reusabl:[16,21],couldn:[21,11,1],yarko:[7,8,29],synchron:28,recov:21,thing:[20,10,11,1,28,2,22,32,13,34,7,21,14],place:[32,10,21,1,12,2,4,16,13,5,17,7,28,14,19,18],greenhous:[37,10],principl:[20,9,21,1,12,36],think:[20,32,10,11,1,28,2,22,16,21,7,14,19],frequent:21,first:[20,9,10,0,1,12,32,28,4,22,16,21,34,6,36,7,27,14,19,35],origin:[10,1,28,14,21,16,35,8,19],directli:[27,0,1,2,10,32,21],carri:[21,11,12],onc:[20,10,28,21,6,7,14,19],arrai:[20,21,12,10,4,32,36,35],getcost:19,crib:30,yourself:[10,12,2,21,32,7],fast:[13,32,10,1],ring:10,open:[10,0,1,12,2,21,13,6,7,28],size:[2,28,10,1,19],given:[21,0,12,28,10,4,34,35],"__subclasses__":[31,4,22],width:[35,28],teardown:1,caught:12,clip1:21,plastic:21,necessarili:[13,0],circl:[4,12],showdigit:12,white:[9,21,1,28],conveni:[27,28,13,10,4,34,19],cite:35,includ:[20,32,10,28,1,12,15,27,16,21,17,7,29,14,19],simionato:14,changeneighbor:28,especi:[20,21,29,10,32,17],copi:[21,12,28,2,34,6,7],specifi:[10,1,12,2,4,32,7],broadcast:12,newcolor:28,enclos:19,enigma:21,changeavail:12,holder:21,than:[20,32,10,11,1,28,13,31,4,22,16,21,34,14,19],png:7,serv:[20,4],setattr:27,min:28,applet:0,were:[21,1,12,10,4,32,14],posit:[35,28],surrog:[11,36,19,34],seri:14,analysi:20,sai:[20,32,10,11,28,12,13,31,22,16,21,0,6,7,14],nicer:[7,36,28],svnroot:10,argument:[20,9,10,11,1,12,4,32,21,5,28,14],ant:10,prt:10,larri:21,deliv:10,breakfast:28,kevin:28,leastsquar:11,engin:[31,0,1],squar:[4,28],patternrefactor:[21,11],note:[1,4,6,7,14,9,10,11,12,13,15,16,18,19,20,21,27,29,28,32,33,34,35],altogeth:[20,21],ideal:10,take:[20,32,10,0,1,12,2,31,28,4,16,21,11,36,7,27,14,19,29],green:28,noth:[20,21,11,1,28,13,35],begin:[20,10,29,13,21,32,7,14],sure:[2,32,10],trace:[14,1,28],normal:[20,27,11,1,31,10,4,32,21],track:[21,12,28,2,34,5],price:[2,21,19,12],setchang:28,beta:10,pair:[21,36],neatli:34,televis:27,latex:[7,13,8,29],synonym:20,later:[20,10,11,1,4,21,7,27,14,19],drive:0,quantiti:[28,27,21,12],addbranch:7,runtim:[9,10,11,4],parseint:28,quiescent:12,shop:[2,19],shot:[21,19],linedata:11,show:[20,32,10,11,1,13,3,15,4,16,21,6,7,27,14],cheat:7,cheap:[20,21],subprocess:10,mousetrap2test:12,concurr:[3,9],permiss:[10,1],hack:[7,8],ground:10,xml:[10,36],onli:[0,1,2,4,6,7,14,10,11,12,13,16,19,20,21,22,27,28,31,32,34,36],explicitli:[32,21,10,14,4],nexta:12,fenc:20,nextc:12,transact:20,observedflow:28,enough:[10,1,28,13,21,4,7],doubleespresso:19,printstacktrac:[21,1],black:[9,1,28],analyz:20,jaroslav:21,clearselect:12,startswith:6,proxy2:34,nearli:1,viewpoint:21,get:[18,9,10,11,1,12,2,31,20,22,32,16,13,6,36,7,28,21,14,19,17],ddaluminum:21,cannot:[20,32,10,0,12,31,27,16,21],ssh:7,afunct:14,gen:4,requir:[20,32,10,1,12,4,16,21,33,5,6,36,7,28,14,19],truli:10,prime:[21,1,28],reveal:35,isemptyxi:35,aluminum:21,dramat:1,yield:[3,31,4,22],spameggssausageandspam:10,expedi:1,pynam:10,scott:20,where:[20,10,11,28,12,2,4,22,32,18,5,6,7,21,14,35],vision:2,summari:[9,10,21],wiki:[10,11,29,21,7,14],balabanov:27,pydictionari:10,booch:21,cafelattewet:19,testcas:[],overwhelm:7,rmi:34,purest:11,concern:[21,14,1],timeit:10,detect:[21,22,35,30],charat:10,review:[7,9,14,1],enumer:[16,6,12,22],label:[10,8,29],getattr:[27,34],trashbinset:21,between:[20,10,1,12,21,34,7,28],"import":[20,10,0,1,12,2,3,4,22,32,13,5,6,31,28,21],item2:22,across:[10,4],aslist:10,assumpt:[31,21],parent:[7,10],tup:10,screen:[21,0,1,28],inflex:19,cycl:32,pythoncardapp:28,findminima:11,come:[20,10,1,12,2,28,4,32,21,6,7,27,35],pythoncard:28,tug:7,newbyt:35,pepperdew:19,quiet:21,contract:2,inconsist:14,improv:[9,27,29,12,2,21,32,13,7],somecondit:1,minima:11,color:[13,35,28],overview:[7,9,21],unittest:[21,10,1,12],period:32,dispatch:[9,21,28,31,4,22],colorbox:28,jeremi:35,colon:[32,10],exuperi:20,mousetrap:12,coupl:[20,9,21],games2:4,west:35,rebuild:10,mark:[20,32],appframework:0,quiesec:12,reflex:20,procedur:21,runal:12,spare:32,emphas:[13,21,10,4],nameless:10,trantabl:12,cafelatteextraespresso:19,findal:6,rememb:[32,21,10,22],lectur:17,"__eq__":[22,12],former:[16,27],those:[20,10,1,28,2,4,22,32,21,5,17,7,14],ispubl:1,sound:[2,14],myself:[14,17],tostr:10,keygen:7,trick:[10,5,21],cast:[10,21,36],invok:[10,1,22,32,21,7,14,19],outcom:[4,22],invoc:19,anytim:[13,28],advantag:[16,21,10,27,12],stdout:10,canon:[9,15],ivi:7,worri:[2,13,16],endswith:[10,6],eras:[1,4],myapp:0,couplet:21,shutil:6,fame:21,"__init__":[32,10,0,1,12,35,28,4,22,16,21,11,5,6,36,27,14,19,34],develop:[20,9,10,1,2,13,7],author:[11,28],blackboxtest:1,same:[20,32,10,11,1,12,13,28,4,22,16,21,34,27,14,19],check:[10,1,12,28,4,32,21,6,7,27,8],binari:7,html:[10,29,13,8,21,32,6,7,14],testrunn:[],customize1:0,pai:[2,10,21],document:[10,1,28,13,8,32,7,14],martelli:27,number_of_processor:30,nest:[32,27,4,19],foam:19,someon:[7,8,28],driven:[37,9,1,12,35],mani:[10,1,12,2,27,32,21,7,28,14,19],extern:[9,21,1,12,6],tosynch:28,tradition:[32,1],hummingbird:28,appropri:[20,10,11,1,12,31,4,32,21],macro:[9,11,14],facad:36,pep8:13,gameenviron:4,without:[20,9,10,21,1,28,2,4,32,16,13,7,14,19],model:[20,31,21,28,19],dimension:[36,12],arrays2:32,execut:[9,10,11,1,28,4,22,32,21,7,14],tip:7,thermostatnight:10,rest:[20,10,0,1,12,2,4,21,6,7,14],recyclea:21,aspect:[20,10,14,4,28],recycleb:21,touch:[31,21],monei:[2,12],flavor:11,speed:10,pythondecoratorlibrari:14,except:[10,0,1,12,22,21,14],littl:[20,10,1,12,21,32,7,14,35],blog:7,pile:20,treatment:21,exercis:[9,10,11,1,12,31,28,4,21,0,17,36,27,19],frontmatt:8,mouseclick:28,real:[10,11,35,34],around:[20,21,1,28,13,31,4,32,34,5,35,14,19],todolist:[8,29],"0079ef2c":27,repaint:[35,28],grid:28,pop:[10,21],amp:[3,1],rununittest:1,appetit:20,returnarrai:10,mod:35,saniti:1,yearli:21,stranger:20,vend:[9,12],chainofrespons:11,integ:[32,10,28],benefit:[10,28,2,21,32,13,34,19],either:[20,10,11,28,22,32,19],output:[10,0,1,12,13,8,27,32,29,7,14,19],margherita:19,manag:[20,10,11,12,28,31,27],fulfil:[20,11,34],tulach:21,satisfactori:21,adequ:[20,32],constitut:28,nonzero:1,regina:19,slice:10,mood:12,chronicl:20,boxobserverpythoncard:28,definit:[21,0,1,2,10,32,34,14],evolv:[13,20,10,21,1],exit:[35,14,1,28,6],inject:[10,14],complic:[21,34,1,19],ratcount:35,refer:[20,27,21,1,12,2,4,22,32,13,34,35,7,19,18],power:[7,21,10,14,27],pythoninterpreterget:10,garbag:[10,1],inspect:[7,6],typedbin:21,standpoint:1,"__name__":[10,11,1,28,31,4,22,32,6,14,19],"throw":[16,10,1,12,4],comparison:[10,4,12],central:[16,21,12],greatli:21,max_num:21,firstnam:7,conditionc:12,panna:19,splitlin:6,currentlin:35,stand:[20,31,21,34],neighbor:28,act:[20,21,11,14],routin:34,effici:21,lastli:[16,10],val2:32,quietli:10,"75f":19,strip:[21,19,1,12,6],counterintuit:21,your:[0,1,2,4,6,7,9,10,11,12,13,15,16,19,20,21,22,27,28,30,31,32,34],wustl:21,log:28,aren:[13,20,36,1,32],commenttag:6,overwrit:6,hee:34,stealth:10,interfac:[20,9,10,11,28,12,31,4,32,16,21,34,36,19],low:[20,21],lot:[20,10,1,12,2,21,32],pollin:31,strictli:21,unam:10,svn:10,tupl:[32,10,5,22],bundl:36,regard:20,vendingmachin:12,stepanov:16,conciev:12,"0076aa3c":27,functor:11,mice:12,conclus:16,faster:[10,1],notat:10,tripl:32,jc2:10,impenetr:1,possibl:[20,10,21,1,12,2,4,32,13,34,35,27,14,19],"default":[21,11,1,28,30,10,7,35],asynchronizedmethod:28,grasp:32,embed:10,clone:[7,21],connect:[20,21,11,28,12,10,27],gone:[10,11],creat:[0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,27,28,29,31,32,34,35,36],certain:[21,10,15,19,12],mode:[2,7,10,6],strongli:32,intro:8,file:[9,10,0,1,12,13,15,21,32,11,6,7,28,8,35],jargon:31,rearrang:16,cream:19,incorrect:16,again:[2,21,10,1,32],setval:10,googl:7,want:[20,32,10,11,1,12,2,28,4,22,16,13,34,5,36,7,27,21,14,19,29],discrimin:32,my_decor:14,compel:[20,10,6],awt:10,orient:[20,21,11,10,4,32,14],idiom:[20,9,11,28,24,34,7],valid:[10,1],compet:22,jset:10,you:[0,1,2,4,5,6,7,14,9,10,11,12,13,15,16,18,19,20,21,22,27,28,30,31,32,34,35,36],getdescript:19,inneradapt:36,architectur:[2,20,10,28],check_result:6,critic:10,inevit:21,registri:10,sequenc:[20,32,10,11,12,21,16],tbin:21,vocabulari:20,pool:27,reduc:[1,19],bulk:[13,21],differentreturn:32,opennotifi:28,directori:[10,1,13,21,6,7,8],descript:[10,1,12,27,21,6,7,8,19],showmsg:32,gradient:20,mass:28,potenti:[20,28],escap:12,fillabl:21,represent:12,all:[0,1,2,4,6,7,14,10,11,12,13,16,18,19,20,21,22,27,28,31,32,34],dist:10,consider:[9,21,19],messi:[21,22,30],recip:9,lack:[10,1],dollar:12,sanitycheck:1,monti:32,abil:[20,28,2,31,13,14],follow:[20,10,21,1,12,2,4,22,32,13,34,5,7,28,14,19],princ:20,unclassifi:21,edong:7,"__cmp__":[10,12],init:0,program:[20,9,10,11,28,1,12,32,2,15,4,22,16,13,6,27,21,14],hasattr:30,rstrip:6,cgi:[32,21],introduc:[20,10,1,2,21,13],"case":[32,10,11,1,28,2,4,22,16,21,34,5,27,14,35],liter:[32,22],straightforward:[20,10,21],fals:[21,10,6,12],checkin:[7,8],faq:7,util:[32,10,1,28,16,7],defvar:7,candid:[16,20],mechan:[9,21,0,13,22,16,32,11,14,34],failur:[20,11,1],veri:[20,9,10,11,1,28,2,4,22,32,13,7,27,14,35],bottleneck:10,bruceeckel:[7,16,10,20,1],lisp:14,list:[20,9,10,0,1,12,2,8,4,22,32,21,11,5,6,7,28,14,29],signific:[13,16,21,1,35],emul:28,small:[2,13,20,19],everth:15,dimens:28,pyobject:10,tea:19,tee:34,tex:7,zero:[10,1],shapefactori:4,design:[20,9,10,11,1,12,13,31,28,4,32,16,21,34,6,36,27,14,19],pass:[10,11,1,12,31,28,4,22,32,21,34,5,36,7,27,14,19],whene:34,further:[9,10,1,28,13,3,21,32,14],new_f:14,what:[1,2,3,4,6,7,14,9,10,11,12,13,16,18,19,20,21,27,28,32,34,36],sub:6,ntotal:21,hashset:10,abl:[20,10,0,1,12,2,4,22,16,13,11,21,35,34],brief:32,overload:[32,10,21],version:[10,21,28,12,2,8,4,22,32,13,36,7,27,14,18],succinct:[10,14],fillbin:21,"public":[20,10,1,2,21,13],contrast:32,movement:[20,21,11],hasn:[21,28],full:[7,32,10,34,6],hash:[16,32,12],variat:[20,27,36,21,12],sophist:[32,10,1,4],rlock:28,shouldn:[7,11],trunk:[7,9,10],demet:20,rudimentari:32,modifi:[10,21,1,12,2,31,28,4,22,32,13,7,27,14],valu:[10,1,12,22,32,21,5,36,14],search:[9,21,0,1,32,7],upcast:[21,4],ahead:[32,1],vegetarian:19,popen:10,prior:21,amount:[21,11,1,12,15,10],"0076daac":27,pick:21,action:[20,9,10,11,12,4,21,34],introductori:[9,10,2,32,7,14],scurri:35,pytupl:10,via:[2,7,10,21,22],shorthand:10,primit:[10,21],transit:[9,12],"while":[20,10,11,1,12,2,21,32,34,35],readili:20,filenam:[21,6,35],inappropri:[10,1],ystart:35,famili:[21,11,22],establish:[16,32,21,1,12],jbutton:10,select:[20,9,10,11,28,12,13,21,7,19],kittiesandpuzzl:4,aggress:32,twa:10,proceed:21,distinct:[20,21,11,12,10,34,27],regist:[7,28],two:[10,0,1,12,2,31,28,4,22,32,21,34,6,36,27,14],coverag:[8,29],getweight:21,repetiti:15,machinediscoveri:30,taken:[13,21,10,1,4],showtot:12,minor:28,more:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,19,20,21,22,27,28,29,31,32,34,35,36],visitabledecor:21,desir:[10,11,5,21,28],mydialog:10,apologet:14,reconfigur:31,convinc:1,ddcardboard:21,flag:[10,28],stick:14,particular:[20,32,10,11,1,12,2,4,16,21,34,35,7,27,19],known:21,compani:[2,10],cach:10,dictat:2,none:[27,10,28,1,12],pyprog:1,jdk:[10,1,28],dev:7,histori:[7,9,14,6],testdemo2:1,remain:[16,21,12],caveat:[18,1],learn:[20,21,2,32,13,7],returnchang:12,statedemo:34,dee:34,def:[32,10,0,1,12,30,31,28,4,22,16,21,11,5,6,36,27,35,14,19,34],prompt:7,scan:13,challeng:35,share:[2,7,27],accept:[7,16,10,21,31],prose:13,minimum:[7,32,10,28],explor:16,explos:21,phrase:1,magenta:28,condemn:21,huge:19,cours:[20,10,1,29,2,4,21,34,36,19],goal:[20,9,10,1,12,2,21,32,14,35],awkward:10,divid:1,programmat:19,anoth:[20,10,11,28,12,31,4,32,21,34,7,27,14,19],comfort:[1,36],myratno:35,ish:[13,32],smalltalk:[20,28],simpl:[9,10,0,1,12,4,32,21,34,36,7,28],css:[8,29],distro:10,plant:21,resourc:[9,1,28,36,8,35],algebra:16,variant:21,reflect:[9,10,21,1],associ:[32,10,21],"short":[32,30],waysid:1,ani:[20,32,10,21,1,12,2,28,4,16,13,34,35,7,27,14,19],confus:[21,28,31,32,36,14],mousemovelist:12,ambigu:10,caus:[20,10,1,12,31,4,21,7,28],flwr:31,drinkcompon:19,egg:[32,27],sysctl:30,help:[20,21,28,2,3,13,34,17,7],soon:1,held:[20,34,12],pythondialog:10,paper:[21,22],through:[20,32,10,11,1,12,2,28,4,22,16,13,34,27,21,14],cyan:28,hierarchi:[20,21,11,31,4,22,34],taxonomi:[20,9],makeschang:12,paramet:11,latt:19,style:[11,1,29,13,12,32,8],conjugategradi:11,alli:17,late:[21,19],rapidli:[10,28],astonish:20,pythondecor:14,match:[31,21,11,22,28],might:[20,10,11,1,28,2,4,22,16,21,14,35],currentst:12,wouldn:[21,1,4],good:[20,10,1,12,2,21,32,13],"return":[32,10,11,1,12,30,31,28,4,22,16,21,34,5,6,36,27,14,19,35],pollut:20,ttbinlist:21,framework:[20,9,10,0,1,12],somebodi:[2,7],placehold:12,complain:32,bigger:[10,12],whatiw:36,intricaci:4,customize2:0,hook:28,solver:11,instruct:[7,1],refresh:[8,6],easili:[20,10,11,1,12,27,22,21,5,36],achiev:[21,10,14,27,19],compris:14,getmodifi:1,found:[20,21,1,14,35,7,8,19],strategypattern:11,proxyadapt:36,harm:[9,21,12],weight:21,hard:[13,16,21,4,31],idea:[20,10,11,12,2,8,4,13,34,17,7,21,14],ndiff:6,realli:[20,21,11,12,10,32,36,27],finish:[20,10,1,12,7,14],expect:[20,10,21,22,32,18,14],windowadapt:28,ddpaper:21,detect_cpu:30,todo:[9,10,29,6,7,8],event:[20,10,0,35,28],flower:[9,28,31],safeti:[32,1],classvariablesingleton:27,multiplejython:10,actionperform:10,setsiz:[35,28],publish:[2,21,10,1],research:[2,10,36],footnot:[20,10,11,1,12,27,21,8],gameelementfactori:4,print:[0,1,2,4,5,6,8,9,10,11,12,13,14,35,21,22,27,28,31,32,34,19],qualifi:[32,1],lutz:32,proxi:[20,9,10,12,27,16,34,36,19],advanc:[2,11],reason:[20,10,11,1,12,2,4,32,21,34,36,14,19],base:[20,10,0,1,12,2,31,28,4,22,32,21,11,7,27,35,34],put:[20,9,10,21,1,12,2,8,4,32,13,5,6,7,27,14,17],teach:[2,9,1,17],bash:1,basi:[1,28],thrown:21,thread:[7,35,28],script:[13,9,10,11,32],struggl:20,revolutionari:1,perhap:[21,1,13,31,10,4,36],pythonsw:10,ascher:32,trashsort:21,lifetim:34,clump:5,assign:[7,14,10,5,32],major:[32,14],notifi:28,obviou:[16,21],blush:21,feel:[7,13,20,1],articl:[3,15],lastnam:7,number:[20,10,11,1,12,30,13,27,22,32,21,34,35,36,7,28,14,19],sometim:[20,10,0,13,21,36,7,14],sayhello:14,done:[10,11,1,29,2,4,32,13,7,28,8],construct:[16,10,14,1],colorboxestest:28,stabl:10,miss:[20,21,10,6],fanci:12,gpl:10,razor:20,differ:[20,32,10,11,1,12,8,4,22,16,21,34,6,31,7,28,14,19],php:28,exponenti:[20,19],interact:[31,10,4,36,22],tove:10,least:[20,10,1,21,32,7],addfactori:4,paint:[13,35],expand:[7,34],statement:[10,11,1,12,4,32,21,34,28,14],scheme:[31,21,28],syrup:19,store:[14,1,12],itempairgen:22,imperfect:13,option:[20,11,28,2,32,6,7,19],relationship:20,behind:[20,34],checklist:20,shapefactory1:4,shapefactory2:4,part:[20,9,10,0,1,28,2,8,21,25,32,23,24,11,6,7,14,19,35],pars:[32,9,21,22],consult:2,closenotifi:28,eventu:[20,1],tortoisehg:7,albeit:[20,32,10,21],kind:[20,32,10,1,12,2,31,4,22,16,21,34,28,14],plop:21,whenev:[20,21,0,28,4,5,7,14],remot:34,gotten:12,remov:[20,21,12,28,2,16],kapow:10,pythoninterpret:10,reus:[20,27,0,12,10,21,11],getconstructor:[10,21],toward:[20,1],danc:34,weapon:31,runsawai:12,comput:[10,21],nastyweapon:4,ardent:1,requisit:1,"null":[34,1,12,35],gettotalcost:19,sell:2,imagin:[21,4],wilson:14,built:[20,9,10,11,1,28,2,21,32,34,7],equival:[32,21,10,1,28],jythonc:10,self:[20,32,10,0,1,12,35,31,28,4,22,16,21,11,5,6,36,27,14,19,34],violat:10,typediter:16,also:[20,32,10,11,1,12,2,28,4,16,13,35,17,37,7,27,21,14,19,29],bgboxobserv:28,build:[9,10,0,1,32,2,31,4,16,13,36,7,21,8],mouseev:28,brace:32,distribut:[7,13,10,4],exec:10,blackboard:35,eater:31,lighton:10,reach:[20,11,35],mixtur:19,addobserv:28,most:[20,10,0,1,28,2,4,21,11,5,14,19],plai:[31,21,4],cygwin:7,eaten:31,thidiscuss:11,maco:30,alpha:10,amaz:[10,14,35],fileread:35,clear:[2,20,14,28,12],cover:[2,13,33,0,1],roughli:[1,12],"_shared_st":27,ext:[8,29],clean:[32,21,10,1],jython2:10,xstart:35,usual:[20,10,0,1,21,32,5,14],mousetrap2:12,mousetrap1:12,ccolor:28,flowergen:31,canvaswidth:35,particularli:[13,32,21,22],uncov:10,font:[2,10],fine:[21,4],find:[20,10,11,1,2,4,32,13,7,21,14,19],impact:[21,14],flesh:10,solut:[20,10,11,1,12,28,4,22,21,27,19],pyutil:10,templat:[9,10,0,12,2,4,32,16,13,11,21,14],darkgrai:[35,28],shapefact1:4,affirm:[32,1],unus:20,cappuccinodecaf:19,express:[20,10,1,13,22,32],entry_exit_class:14,swing:10,nativ:[7,10],mainten:[21,19],wateroff:10,ineffici:28,doubli:28,cyclic:12,stl:[16,10,11],common:[20,10,1,12,2,4,32,21,34,17,28],wrote:[10,1],commod:21,cafemochawetwhip:19,pyexcept:10,adopt:1,creator:[7,11,29],cleverli:13,startup:[7,10],potent:10,emac:[7,9,8],bare:28,aluminumbin:21,arg:[27,1,28,10,32,21,7,14,35],close:[28,1,12,35],horizont:35,skill:11,analog:32,dwarf:31,expert:[13,11],someth:[20,10,11,1,12,2,31,22,32,13,17,36,28,21,14,19],particip:7,conditionb:12,conditiona:12,weakli:[],testb:1,won:[10,28,2,21,32,13],mutex:28,autogener:[8,29],experi:[2,20,10,14,1],nope:1,birkenfeld:7,altern:[20,10,1,3,21,14],signatur:[32,10],str:[32,28],numer:[0,5,11,22],hasnext:[16,21,10,1,12],complement:20,sole:11,isol:[20,21,11,4],statemachin:[9,12],disallow:4,cachedir:10,getmethod:[10,21],solv:[20,10,11,1,12,3,22,32,21,34,36,31,28,35],extraespresso:19,both:[20,10,28,13,4,22,32,21,34,35,7,27,14,19],"__instanc":27,last:[31,10,0,21],hyperlink:8,arraylist:[10,21],alon:[21,28],undetermin:0,context:[9,11,8],forgotten:15,commandpattern:11,whole:[21,11,1,12,2,10,28],load:[21,10,4,36,7,35],randomli:[31,1],simpli:[20,32,10,0,29,12,31,21,16,34,5,36,28],point:[20,27,11,1,12,30,2,4,32,13,7,28,21,14,35,18],schedul:[31,10],sweep:1,arbitrarili:[10,34],header:7,templatemethod:0,loveandtheft:14,param:10,linux:[7,8,30],throughout:[20,21,0,1,13,4],identif:21,java:[9,10,1,12,32,4,22,16,21,34,6,18,28,14,35],dum:34,due:1,empti:[35,28],implicit:14,mercuri:[7,9,8,29],newinst:[21,1],nois:1,pushnew:7,strategi:[9,11,6],addison:[21,11],versa:32,execfil:10,clariti:[13,19],imag:[13,28],remark:[32,10,21],coordin:35,changeimp:34,understand:[20,10,12,13,27,32,21,14],demand:[2,32,34,1,4],makedir:6,fillablevisitor:21,look:[20,10,11,1,12,13,8,28,4,32,21,34,31,7,27,14,19,29],packag:[32,21,10,1,12],frozen:28,buildtabl:12,getquant:12,decrquant:12,smart:[10,34,12],abov:[20,10,11,1,28,2,8,15,4,32,13,34,31,7,27,21,14,19],error:[21,1,12,13,10,6,28],fun:14,anonym:[9,21,37],fum:10,everyon:[29,28,2,32,13,17],loop:[20,21,0,10,4,32],pack:10,argin5:10,propag:[20,21,28],pound:32,argin1:10,argin3:10,argin2:10,readi:[2,7,21,0,35],petal:28,itself:[20,10,11,12,13,21,14,35],orgpattern:21,coroutin:[3,9],chase:4,decor:[9,27,28,14,21,16,8,19],guido:29,restructur:[2,7,6,13,9],minim:[20,1,28],boxwidth:28,belong:2,on_openbackground:28,shorter:10,read:[20,9,10,0,1,12,30,2,3,21,32,6,28,14,35],conflict:7,higher:7,cappucino:19,vertdir:35,optim:[10,21],painless:21,wherea:[32,10,11,21,12],ponder:20,setbackground:35,user:[9,10,28,12,2,4,16,21,7,27],stack:28,focal:20,recent:[10,1],lower:20,task:[7,13,28],lib:32,eleg:[20,27,21,32,34,14],entri:[13,8,10,14,35],localarrai:28,propog:28,parenthes:32,person:[7,10],testpythontojavaclass:10,chees:12,expens:[21,34],elev:[21,12],academ:1,imit:[7,32],propos:[7,20],explan:10,pyfloat:10,valueof:21,obscur:20,choru:34,world:[20,10,11,14,1],"67f":21,dumpclassinfo:10,dirlist:11,cut:[21,36,28],indexof:[10,21],mydecor:14,getreturntyp:1,snag:28,win:[31,10,22],input:[3,0,12],subsequ:[32,12],brainstorm:20,bin:[7,21,10,1],tomap:10,vendor:[31,21],format:[2,7,32,13],big:[32,10,14],intuit:10,game:[4,28],alias:34,insert:[32,21,27,6],verion:7,bit:[32,10,28,2,21,4,16,34,14],characterist:0,formal:[32,14],lost:[10,21],docutil:[],signal:10,resolv:21,fluf:13,collect:[20,21,11,1,12,27,36],"__new__":27,sizeabl:19,javabean:10,encount:[21,1,28,10,4,16],sketch:13,often:[20,10,11,1,12,2,31,15,21,32,13,5,17,36,28,14,19],acknowledg:[20,32],creation:[20,9,10,21,1,12,2,28,4,32,16,13,27,14],some:[0,1,2,3,4,5,7,8,10,11,12,13,14,17,35,20,22,21,29,28,30,32,36],back:[20,10,11,1,12,2,21,28,14,35],global:[10,1],understood:[10,1],wxpython:28,mirror:20,sprint:2,mindview:10,mousepress:28,syndrom:21,rien:20,scale:[3,10,1],chocol:19,mousemov:12,though:[21,27,14,1,28],per:[20,28,19,12,32],usernam:7,substitut:[32,14],mathemat:[11,22],larg:[2,3,21,33,12],market:31,fornam:[21,1],reproduc:2,norvig:28,machin:[7,9,12,30],previou:[21,12,2,4,14,19],run:[20,9,10,0,1,12,21,32,11,6,7,28,14,35,34],martin:[21,14],agreement:10,stem:10,step:[20,32,10,1,2,4,16,21,7],initialst:12,subtract:20,impos:[16,12],sellimaginaryproduct:31,constraint:[20,32,21,12,2,16,14],materi:[2,13,10,17],memori:1,libero:12,dialog:10,cappuccinodrywhip:19,block:[13,6],plan:10,predat:31,repair:21,"__future__":[31,4,22],pythonpath:32,within:[20,21,28,12,10,4,32,14],oreilli:32,"caf\u00e9":19,contributor:[2,9,8,29],chang:[20,9,10,0,1,12,13,31,28,4,21,33,34,6,36,7,27,14,19],artifici:1,connector:20,inclus:[20,32],institut:1,spam:[32,27,28],valuminum:21,question:[7,20,10,21,12],submit:1,custom:[7,10,0,21,19],clip3:21,clip2:21,adjac:28,arithmet:35,pocoo:[8,29],clip4:21,forward:[20,10],jarrai:10,blueprint:[2,7],convert:[10,0,12,28,16,8],properli:[21,10,14,22],hawaiian:19,sc_nprocessors_onln:30,link:[7,13,11,8],translat:[20,9,10,21,1,12,2,4,22,16,13,28,8,35],delta:6,line:[9,10,0,1,12,8,15,21,32,11,5,6,7,28,14,35],talli:21,info:[21,5,28],concaten:32,consist:[20,21,1,28,13,4,32,19],caller:[21,4],strang:[32,4,12],jpython:10,priveleg:10,fillrect:[35,28],readlin:[10,21,12,35],similar:[20,10,11,1,12,21,32,34,28,14],toomuchaccess:1,parser:21,chao:1,doesn:[20,10,21,28,12,2,8,27,22,32,13,6,36,14],repres:[32,21,12],"char":[10,35],guarante:[7,12],cafe:19,fulful:11,titl:[10,28],water:10,windowi:7,appendic:13,intvalu:10,tbinlist:21,"_imag":13,addmouselisten:28,getbound:35,cappuccinoextraespresso:19,nice:[2,7,32],draw:[0,4,35,22],getdeclaredclass:1,cappuccinoextraespressowhip:19,state_d:34,topydictionari:10,eval:[4,22],itemavail:12,pricevisitor:21,lang:[10,21],algorithm:[20,9,21,11,28,4,16,35],vice:32,downcast:21,actionlisten:10,entryset:10,normpath:6,tradeoff:19,jpanel:28,greenhousecontrol:10,mindlessli:21,karma:[2,13],far:[20,32,21,1],java2pi:10,hello:[10,14,12],prototyp:[20,9,10,21],code:[0,1,4,6,7,8,9,10,11,12,14,15,16,17,35,20,21,28,31,32,34,19,37],partial:32,hashmap:[10,21,12],scratch:[10,14],tclone:21,overlap:28,edu:[21,14],benevol:2,privat:[27,0,1,28,10,7],successfuli:10,elsewher:13,friendli:1,send:[2,32,10,34,21],granular:1,becam:1,paperscissorsrock2:22,sens:[20,10,11,1,4,32,21,5,14,19],junit:1,sent:10,func2:14,func1:14,cheapli:[10,21],mainstream:14,sausag:27,mous:[28,12],testdemo:1,electron:[2,13],chdir:1,volum:[2,13],whatius:36,implicitli:[20,32,10,4],kitti:4,tri:[10,11,21],troup:32,magic:27,succeed:11,counterproduct:21,knight:34,button:[7,10,4],hive:27,"try":[20,10,11,1,28,13,21,36,7,14,35],session:12,mousetraptest:12,pleas:[2,7,8,18],boxobserv:[1,28],fortun:21,readabl:32,natur:[21,1,28,13,32,14,35],verbiag:32,elisp:7,jump:14,slithi:10,binset:21,singletondecor:27,download:[2,7,10,16,28],odd:[34,19],click:[7,13,28],append:[10,11,1,28,32,6,7],compat:29,index:[9,10,11,13,21,5,7,8],getclass:[16,31,10,21,12],compar:[7,21,10,11,1],espresso:19,access:[27,1,28,4,32,34,14],deleteobserv:28,runuculu:31,mouseadapt:28,spoken:21,whatev:[13,21,1],ibid:20,absolut:32,len:[11,35,1,28,6],closur:14,let:[10,1,12,13,4,21,14,19],becom:[20,32,10,1,12,21,16,28,19],sinc:[20,10,11,1,12,4,32,21,34,28,14,19],great:[2,18,10,20],talent:2,convers:10,musser:16,larger:[21,29],makec:36,makeb:36,makea:36,fetch:[21,28],staticmethod:[27,14,4,36,6],earli:[13,18,10,1],typic:[20,21,11,1,12,32,0,5,14,19],ratcanmov:35,evalrock:22,chanc:11,transitiona:12,appli:[20,21,12,1,28,32,36,14],app:28,foundat:[9,23],"_updat":6,pyton:10,fillablecollect:21,hennei:20,"boolean":[10,21,12,35],notenough:12,limb:14,newimp:34,puriti:10,fee:10,from:[0,1,2,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,27,28,30,31,32,34,35,36,37],sysconf:30,zip:[7,6],commun:[2,10,35],doubl:[9,21,31,10,4,32,22,27],addtrash:21,whatihave3:36,whatihave2:36,implic:19,few:[5,19],camera:2,usr:[7,1],stage:[20,21,19],remaind:[7,9,21,8],sort:[20,32,10,11,21,16],clever:20,src:7,tplus1:14,impress:[10,21],train:2,bufferedread:35,iii:[9,25],starter:35,account:[7,1,19],alik:2,retriev:[],when:[20,10,11,1,12,2,31,4,22,32,18,34,35,36,7,28,21,14,19],annot:[14,12],thin:4,meet:[31,21,12],scatter:21,aquamac:7,proof:21,control:[20,9,10,11,28,12,13,4,32,21,34,7,27],cafemochawet:19,process:[20,32,10,0,1,12,13,4,22,16,21,11,7,14,19],lock:[2,14],high:[20,21],tag:[13,4,12],trashvisitor:21,csum:21,onlin:[13,28],kevlin:20,delai:[10,12],friendlier:7,comedi:32,georg:7,shapenamegen:4,sig:10,feta:19,subdirectori:[21,10,1,6],instead:[20,10,11,1,12,4,22,21,7,28,14,19],sin:10,stock:7,overridden:[32,21,0,1,12],pyarrai:10,hazard:11,callback:[21,11,28],rmtree:6,multipl:[9,10,11,28,13,31,27,22,32,21,7],"120dpi":7,cheaper:20,physic:35,alloc:1,drop:21,essenti:[20,21,11,1,10,32],seriou:1,correspond:[21,5,1,19],element:[20,21,1,12,10,32,14],issu:[13,20,27,21],allow:[20,10,11,29,12,31,4,21,0,28,14,34],subtyp:21,horizdir:35,espressodecor:19,move:[20,10,11,1,12,2,21,13,35,7,28,8,29],evolutionari:21,comma:32,bunch:21,perfect:[2,13,21,20],outer:[27,10,36,1,28],chosen:[2,28],settitl:28,gnomesandfairi:4,newsgroup:7,decaf:19,criterion:28,tst:1,typemap:21,rat:[9,35],factor:[20,32,10,1],greater:10,"__getitem__":10,handl:[20,32,21,0,8],auto:7,spell:2,dai:[2,10],ctor:21,devel:7,dat:21,mention:[2,21,11,1,4],snake:32,front:[9,34,19],strive:21,multiprocess:3,somewher:[7,4,28],anyth:[20,10,1,28,2,21,13,14],edit:[7,9,21,16,32],tran:12,quest:20,trap:12,isclass:6,batch:32,reserv:1,newtonsmethod:11,psum:21,flair:13,subset:[21,19],chung:27,tolist:10,openobserv:28,transitionb:12,transitionc:12,nodecor:19,"static":[20,10,1,12,4,32,21,6,36,27,19],"_delta":6,whet:20,our:[10,14,21],patch:[7,28],transitiont:12,special:[21,10,4,32,34,7],out:[20,9,10,21,1,12,30,2,28,4,22,32,13,7,27,14,18],variabl:[7,32,27,12],matt:14,contigu:28,cwr:35,dongwoo:7,stub:34,texliv:7,suitabl:10,rel:21,leverag:10,ref:7,"23f":21,math:[10,21,28],clarifi:2,insid:[10,1,12,4,32,21,36,7,28,14],sortintobin:21,manipul:[16,10],standalon:7,dictionari:[10,12,4,22,32,5,36,8],tempt:34,releas:[28,1,12],embarrass:1,correcton:2,could:[20,10,11,1,12,2,28,4,32,21,34,5,27],ask:[20,10,28,4,16,21,35,7,19],membership:21,keep:[20,10,21,1,12,2,4,13,34,5,7,28],length:[21,12,1,28,13,10,35],enforc:1,outsid:[32,21,10,4],south:35,softwar:[7,1],qualiti:[20,1],scene:34,echo:[],date:10,set:[9,10,0,1,12,2,28,4,22,32,21,11,6,36,7,27,14,19],flyweight:12,newsingleton:27,facil:2,redund:11,cafemochaextraespressowhip:19,prioriti:7,"long":[10,21,2,4,32,13,34,7,27,14,19],start:[20,9,10,0,1,28,30,2,27,22,13,7,21,14,35],unknown:[21,22],licens:[2,9,10,27,17],perfectli:12,mkdir:10,system:[20,10,11,1,12,30,2,31,15,4,22,13,7,21,35,18],messag:[20,10,12,1,28,32,7],attach:[13,9],termin:[32,11,1,35],"final":[20,10,0,1,28,2,31,21,13,35,7,14,19],shell:[7,32,10],rsa:7,exit_on_clos:[10,28],slider:4,rst:[2,7,8,6],exactli:[32,10,21,19],readlinelib:10,haven:[13,21],python3pattern:[7,8],cpython:10,embodi:20,split:[6,28],see:[0,1,2,4,6,7,8,10,11,12,14,16,18,19,20,21,27,28,32,34,36,37],structur:[20,9,10,11,1,12,21,16,32,34,35,19],charact:[10,4],bind:[2,21,22],steer:35,imho:32,aggreg:21,isstat:1,clearli:[20,21,19,1,12],have:[0,1,2,4,6,7,14,10,11,12,13,15,16,17,18,19,20,21,22,27,29,28,31,32,34,36],tabl:[9,12,31,22,16,32,34,37],need:[0,1,2,4,5,7,8,10,11,13,14,17,19,20,21,22,27,28,29,31,32,34,36],imatix:12,turn:[20,10,1,12,2,21,32,34,35,28,8,19],gentli:14,lightgrai:[35,28],messeng:[9,21,11,12,5,6],rout:20,rmic:34,mix:21,discret:10,sei:1,which:[0,1,2,3,4,5,6,7,14,10,11,12,13,15,16,19,20,21,22,27,28,31,32,34,35],linda:16,singl:[10,11,28,12,13,4,22,32,21,34,7,27,14],uppercas:0,entry_exit:14,"5b0":10,htmlhelp:7,who:[21,28,29,2,13,17,7,8],minimasolv:11,discov:[20,9,21,1,30,13,4,7],rigor:1,textui:[],mactex:7,"class":[0,1,4,5,6,14,9,10,11,12,16,35,20,27,22,21,28,31,32,34,19,36,37],changealgorithm:11,wikic:21,gather:20,request:[20,11,35,12],face:21,pipe:10,bui:2,michel:14,determin:[32,21,11,12,4,22,16,35],fowler:[21,14],occasion:1,constrain:1,fact:[20,27,1,28,10,32,21,14],statemachine2:12,dbm:12,text:[9,12,2,15,32,13,6,7,35],whatiuse2:36,bring:[20,10,2,21,32,14,35],developerguid:8,debat:13,trivial:[21,10,1,12],anywai:[13,32,11],pythoncardprototyp:28,redirect:[27,10,1],textual:28,locat:[10,11,1,12,21,7,8],launchpad:[2,13],createbox:28,hadn:12,winner:31,jar:10,mug:19,should:[20,32,10,11,1,12,13,3,4,16,21,35,7,28,14,19],smallest:[21,19],suppos:[21,1,28,10,4,32,14],esqu:32,disciplin:14,inhabit:31,local:[20,21,28,2,7,19],hope:[20,8,17],overidden:12,contribut:[2,7,29,13,9],espinc:21,ludicr:21,familiar:[7,16,21],disagre:6,autom:[21,1,12,13,15,10],regularli:[21,19],piecewis:11,bean:10,increas:1,applicationframework:0,triangl:4,extract:[21,10,1,6],enabl:[10,14],organ:[2,7,21,20,1],bisect:11,coplien:[21,11],grai:28,stuff:13,integr:[32,21,11,1,28],contain:[20,9,10,28,12,4,32,16,21,6,36,7,27],grab:21,ddglass:21,view:[13,28],conform:19,"0079e10c":27,frame:[10,35],knowledg:[32,1,4],popen2:30,dynatrash:21,temporarili:10,distract:10,py2int:10,syntact:31,polymorph:[9,21,31,4,22,32],statu:21,wire:[27,21],dlg:10,correctli:[7,1],pattern:[20,9,10,11,1,12,31,28,4,16,21,25,6,36,7,27,14,19,34],boundari:[7,10],misus:[20,21],tend:[20,32,21,1],favor:20,state:[20,9,27,11,28,12,4,32,21,34],japplet:0,progress:[7,8,14],email:[7,20],pazzaglia:16,bed:28,kei:[21,12,31,10,22,32,36,7,19],p2j:10,itertool:[26,9],job:[2,32,21,0],entir:[20,10,28,21,32,14],measur:13,cafelattedecafwhip:19,addit:[10,1,12,2,21,32,34,7,28,14],exclaim:32,boxheight:28,admin:13,invulner:21,equal:[20,21,10,1,32],etc:[21,11,2,4,22,18,0,7,14,19],admit:[20,21],instanc:[27,1,12,10,22,19],equat:14,section:[20,10,31,21,4,33,36,7,8],freeli:[16,10,1],comment:[7,32,10,1],make_fil:6,interp2:10,"0076c54c":27,simpleclass:32,wall:35,guidelin:[13,21],kungfugui:4,arriv:21,chmod:10,walk:[20,10,1,6],distinguish:[21,10,8,1],incess:29,respect:21,labor:20,quit:[10,1,12,13,4,32,14,19],htmldiff:6,decent:20,obstacl:4,compon:[16,28,10,21,19],treat:[21,10,1,12],nextto:28,immedi:[21,14,1,35,4],interactwith:4,assert:[36,1,12,4],espressoconpanna:19,togeth:[10,11,21,32,34,36],present:[20,21,1,12,10,36,19],multi:12,main:[10,0,1,28,2,21,32,7,35],plain:[7,19],align:32,harder:10,defin:[20,32,10,0,1,12,28,4,16,21,5,27,14,19],aarrgggh:35,decept:10,observ:[20,9,27,1,12,21,28],cafemocha:19,htmlbutton:10,layer:[20,19],almost:[20,10,28,31,32,14],site:[2,21,11],motiv:[2,9,10,20,1],fiddl:34,incom:2,revis:21,cafemochadecaf:19,whatihav:36,bolder:1,insight:[20,21],began:[20,1],classpath:[32,10,1],cross:[2,13,10],member:[21,1,28,2,31,22],python:[1,2,4,6,7,8,9,10,11,12,13,14,15,18,19,20,21,22,27,29,28,30,32,33,34],tendenc:21,fill:[10,21],infer:32,difficult:[20,10,12,2,21,32,19],competit:28,http:[10,11,1,12,8,21,29,7,28,14,35],original_new:27,denot:32,expans:[10,12],drink:19,upon:[31,10,14,21],effect:[27,11,1,12,4,22,21,36,28,19],coffe:[9,19],handi:28,issuccess:11,tribut:22,pdf:[2,7,13,9],canva:35,decoupl:[16,9,11,28],misappl:21,pull:[7,21,10,8,6],off:[20,10,28,2,15,21,32],center:10,albin:21,firstli:19,builder:10,well:[20,10,1,28,2,21,13,5,35,14,19],difflib:6,numerical_integr:11,thought:[20,27,11,29,21,16],scissor:22,weblog:14,exampl:[0,1,2,4,6,7,8,9,10,11,12,13,14,19,20,21,22,27,29,28,31,32,34,35,36,37],command:[9,10,0,1,15,32,11,6,7],setq:7,choos:[9,10,11,1,2,4,21,7,8,19],breaker:20,latest:7,test1:[10,1],test3:[10,1],test2:[10,1],test4:10,less:[20,21,1,13,5,14,19],hybrid:10,trust:1,heavili:[16,21],cafelatt:19,simultan:[7,21],gliffi:13,web:[2,32],rapid:10,newbrain:11,field:[10,12,1,28,13,32],bell:[10,21],makefil:[10,8,1,29],knew:1,proxydemo2:34,add:[1,2,4,6,7,8,10,11,12,13,14,15,17,19,20,21,22,27,28,31,32,34,35],jython_hom:10,wet:19,collis:35,ought:12,confront:27,jython:[9,10,8],royalti:[2,10],elementat:35,fate:21,sumvalu:21,piec:[20,21,27,6],arguabl:[10,21],testa:1,camelcas:13,realiz:[16,20,21,1,32],know:[10,21,1,28,2,8,22,13,7,14],press:[32,10],redesign:21,height:[35,28],recurs:[21,11,4],loss:19,trash:[20,9,21],resid:32,like:[20,32,10,11,1,12,2,31,28,4,22,16,13,34,17,7,29,21,14,19,35],success:[20,10,11,1,21,16],incred:32,paperbin:21,necessari:[21,0,1,12,10,32,34,36,7],lose:[21,10,22,31],resiz:[32,0],boxdesc:28,page:[7,9,11,14,32],poor:21,sum:[32,21],trashbin:21,captur:[10,14],suppli:10,phenomena:28,cafemochaextraespresso:19,growth:19,"export":[7,10],superclass:10,flush:1,proper:[10,21,12],home:[7,10],peter:28,librari:[9,10,11,1,28,30,16,32,5,36],simple2:32,tmp:1,"__setattr__":27,est:20,lead:20,bintyp:21,avoid:[7,20,21],setlayout:28,slide:17,"__getattr__":[27,34],leav:[21,28],itemnotavail:12,speak:[2,34],getnam:[21,1],myfunct:32,hinder:32,weslei:[21,11],slower:[20,10],investig:35,usag:[20,9,21,1],facilit:[21,28],host:[2,7],although:[20,10,21,1,2,4,13,5,7,14],offset:28,beneath:0,simpler:[20,21,1,28,27,34,14],about:[20,9,10,21,1,12,30,2,8,4,22,16,13,35,36,7,14,19,32],quarter:12,actual:[20,32,10,11,1,12,4,22,16,21,34,6,28,14],column:28,purist:21,javaclass:10,mindviewinc:[],bridg:10,constructor:[10,0,1,12,28,4,32,21,27,14],wxcommandev:28,"0076b7ac":27,own:[20,10,28,1,12,2,15,4,22,32,21,33,34,6,7,27,8,19,35],fillov:35,bashrc:10,automat:[9,10,11,1,12,13,15,4,32,21,34,5,6,36,7,28,29],guard:20,getpric:12,awhil:20,rectifi:[21,14],pitfal:32,forget:21,mere:10,merg:[7,9,8],prozac:12,val:[32,21,10,27,28],transfer:[9,5,12],inner:[9,10,1,28,27,21,36,37,14],arg1:[32,14],maze:[9,35],typenum:21,arg2:[32,14],"function":[9,10,11,1,12,32,3,28,4,22,16,21,5,31,7,27,14],mailer:7,north:35,pythontojavaclass:10,subscrib:20,bodi:[32,21,11,14],gain:2,eas:[21,19,12],highest:7,bug:[7,31,21,1],count:[32,1,12],made:[10,12,28,29,13,21],cleanup:1,newval:21,whether:[10,11,12,28,2,21,35],wish:[10,1,19],scroll:10,displai:[32,10,14,1,6],troubl:[7,32,10],record:35,below:[7,10,11,28,19],limit:[32,10,14,27],testfil:6,trepid:14,otherwis:[20,21,11,1,28,2],problem:[20,32,10,11,1,12,3,28,4,22,16,21,34,36,31,27,14,19],jdialog:10,evalu:12,"int":[21,12,1,28,30,10,8,35],dure:[10,1,12,2,21,16,34,14],twist:21,implement:[20,9,10,11,1,12,31,4,32,21,34,35,36,28,14,19],decorator_function_with_argu:14,eric:[34,28],probabl:[20,10,11,28,13,22,32,21,34,5,14],typemapadapt:21,nonetheless:14,entry_exit_funct:14,detail:[20,9,27,11,28,30,31,21,7],virtual:[21,0,12,31,4,32,34,7],preinstal:7,other:[0,1,2,4,7,8,9,10,11,12,13,14,15,16,19,20,21,22,27,28,31,32,34,35,36],lookup:[31,22],futur:[2,10],branch:[7,9,21,8,35],bazzar:13,repeat:[20,11,28,4,7,19],star:27,fulli:32,multipledispatch:22,cafelatteextraespressowhip:19,singleton:[20,9,27,36,12],lightoff:10,mazework:35,stai:[20,21,11],experienc:32,sphinx:[9,29,2,13,7,8],interp1:10,came:[16,20,21],indirectli:21,rule:[20,9,10,1,13,32],cpu:30,portion:1,klass:[27,28]},titles:["Building Application Frameworks","Unit Testing & Test-Driven Development","Introduction","Coroutines & Concurrency","Factory: Encapsulating Object Creation","Messenger/Data Transfer Object","Comprehensions","Developer Guide","ToDo List","Python 3 Patterns, Recipes and Idioms","Jython","Function Objects","StateMachine","Book Development Rules","Decorators","A Canonical Form for Command-Line Programs","Iterators: Decoupling Algorithms from Containers","Teaching Support","A Note To Readers","Decorator: Dynamic Type Selection","The Pattern Concept","Pattern Refactoring","Multiple Dispatching","Part I: Foundations","Part II: Idioms","Part III: Patterns","Generators, Iterators, and Itertools","The Singleton","Observer","Contributors","Discovering the Details About Your Platform","Visitor","Quick Python for Programmers","Python 3 Language Changes","Fronting for an Implementation","Projects","Changing the Interface","Table-Driven Code: Configuration Flexibility"],modules:{},descrefs:{},filenames:["AppFrameworks","UnitTesting","Introduction","CoroutinesAndConcurrency","Factory","Messenger","Comprehensions","DeveloperGuide","ToDo","index","Jython","FunctionObjects","StateMachine","Rules","PythonDecorators","CanonicalScript","Iterators","TeachingSupport","NoteToReaders","Decorator","PatternConcept","PatternRefactoring","MultipleDispatching","Part1","Part2","Part3","GeneratorsIterators","Singleton","Observer","Contributors","MachineDiscovery","Visitor","QuickPython","LanguageChanges","Fronting","Projects","ChangeInterface","TableDriven"]})
1
Search.setIndex({desctypes:{},terms:{defaultcloseoper:10,orthogon:20,yellow:29,four:[13,35,12],secondli:19,prefix:29,sleep:[35,29],dirnam:[1,6],"00798f9c":21,browse_thread:7,gladiolu:31,evalscissor:22,whose:[16,27,11,22,29],selen:7,concret:[27,1,4],swap:[34,29],under:[20,10,11,1,12,2,16,34,7],testabl:1,worth:[27,10,4],lure:12,everi:[20,32,10,1,12,2,4,16,27,29,8,19],risk:28,inventfeatur:31,matchobj:6,rise:20,lurk:10,voic:[2,13,1],decorator_without_argu:8,govern:12,affect:[27,29],disturb:[27,4],nestedshapefactori:4,ref:7,decorator_with_argu:8,correct:[10,27,12],"__templatemethod":0,getdeclaredmethod:1,math:[10,27,29],verif:1,unpredictableperson:12,cappuccinowhip:19,c02:1,cmp:12,storag:21,"10f":27,direct:[20,9,10,12,4,8,35],sourceforg:[10,29],nail:27,hors:32,classcastexcept:16,"__finditem__":10,even:[10,11,1,13,27,32,18,34,7,21,8,19],hide:[20,27,36],createshap:4,canvasheight:35,item1:22,weren:21,shallowai:11,firstdigit:12,"new":[20,32,10,0,1,12,2,3,15,4,22,16,13,11,6,31,7,27,14,19,35],net:[10,1,29,2,13,7],ever:[16,27,22],succumb:1,liberti:36,told:4,getsiz:29,widget:29,abov:[20,10,11,1,29,2,8,15,4,32,13,34,31,7,21,27,14,19],never:[2,27,10,21,1],here:[1,2,4,5,6,7,8,10,11,12,13,14,15,16,17,18,19,20,27,22,21,29,30,32,35,36],fun:8,debugg:7,gridlayout:29,path:[27,1,12,10,6,7,29],cardboard:27,interpret:[20,9,10,11,27],dry:19,sweeet:7,haschang:[29,12],credit:[13,9],loop:[20,27,0,10,4,32],studi:[20,27,1,29,4],readlinesetup:10,portabl:[10,4],tremend:10,golden:20,propag:[20,27,29],"_test":6,brought:[7,32,10],substr:27,unix:30,ratsandmaz:35,wateron:10,total:[10,27,12],unit:[9,10,1],getchar:10,plot:29,redon:13,describ:[20,32,10,1,12,2,31,27,16,34,5,7,19],would:[32,10,0,1,12,2,29,4,16,27,11,17,21,8,19],quickpython:32,call:[20,32,10,0,1,12,31,29,4,22,16,27,11,6,36,7,21,8,34],typo:13,recommend:27,type:[20,9,10,11,1,12,32,31,29,4,22,16,27,36,7,21,19],until:[20,10,11,12,31,27,32,6,18,8],looni:11,relat:[20,34],notic:[27,1,29,31,22,10,32,4,8],hurt:29,warn:[20,10,14,27],glass:27,loss:19,flowervisitor:31,moin:8,hole:1,hold:[10,11,12,13,27,16],unpack:[10,27],must:[10,11,1,12,2,31,29,4,22,32,27,5,35,36,7,21,8,19],join:[10,6],err:[27,1],setup:[7,1,4],work:[20,9,10,27,1,29,32,2,8,4,22,16,13,34,6,7,21,14,19,18],worm:31,introduc:[20,10,1,2,27,13],root:[27,1],overrid:[27,0,1,29,12,32,7],walk_comprehens:10,give:[20,10,1,30,2,27,32,13,7,8,35],digit:12,indic:[9,10,29,12,27,4,32,28,8],setvis:[10,35,29],unavail:12,unassign:7,keep:[20,10,27,1,12,2,4,13,34,5,7,29],addtobin:27,end:[20,10,11,29,2,27,22,32,13,14,35],quot:32,ordinari:[27,10,1,29,4],classifi:[20,9],revisit:[27,4],how:[20,32,10,11,1,29,2,31,15,4,22,16,13,7,21,27,19],hot:19,disappear:[18,35],env:1,regist:[7,29],answer:[7,27,1,22],verifi:[10,1],changeinterfac:36,perspect:[20,27],"void":[10,1],updat:[29,28,6,7,14,35],my_new:21,recogn:[],lai:1,mess:2,coffeeshop:19,after:[20,10,11,1,12,8,27,32,35,7,21,14,19],implementation1:34,lump:34,implementation2:34,diagram:[9,27,12,13,34,7,14,19],befor:[20,32,10,11,1,12,2,27,16,29,8,19],wrong:[27,10,1],beauti:[27,34],law:20,parallel:[20,3],demonstr:[10,0,1,29,12,31,22,32,34],beanmeup:19,chere:7,profess:17,attempt:[20,27,1],third:27,classmethod:21,revolv:20,exclud:1,wink:0,maintain:[20,27,11,12,13,22,35,8,19],environ:[7,31,27,4,30],incorpor:[10,11,8,1],enter:[10,8,29,12,35],lambda:10,someplac:7,order:[32,10,0,29,12,2,4,16,27,11,5,7,14,19,34],oper:[20,9,10,11,32,12,31,15,4,22,16,27,7,8],composit:20,softwar:[7,1],over:[20,32,10,11,1,2,27,16,8],failur:[20,11,1],orang:29,becaus:[20,32,10,1,12,2,31,29,27,16,13,34,36,7,21,8,18],paperscissorsrock:[31,22],flexibl:[20,9,10,11,12,27,22,32,37,19],vari:[20,11],fit:[20,27,11,1,29,2,34],fix:[27,28,29,13,31,21,7,14,19],avocado:19,"__class__":[31,10,11,22,19],bytecod:10,better:[20,10,11,1,12,2,27,13,29,8],imp:[16,34],blemang:32,comprehens:[9,10,6],hidden:[32,27,0,34],schmidt:27,easier:[20,10,1,12,31,5,7,29,8],glassbin:27,them:[20,32,10,11,1,29,2,31,27,22,16,13,35,6,7,8,19,17],thei:[20,32,10,11,1,12,2,31,29,27,16,13,6,36,21,8,19],proce:7,safe:[16,9,10,8],stringformat:32,"break":[27,1,28,19,35,6],promis:27,setvalu:27,"instanceof":27,choic:[27,11,29,2,31,4,22,13,35,7,19],grammat:2,alex:21,brough:[],getvalu:[10,27,12],closeobserv:29,each:[20,9,10,0,1,12,31,29,4,22,32,27,11,35,6,21,14,19,34],debug:[10,14,28],side:[7,13,10,27,1],mean:[20,32,10,11,1,12,13,31,27,16,34,29,8,19],prohibit:27,setdefaultcloseoper:[10,29],nochang:12,enorm:8,arduou:19,taught:11,makecharact:4,receptacl:27,collector:10,whip:19,goe:[13,32,27,19],langug:10,gof:[20,11,34],content:27,rewrit:[10,2,8,27,16,13,34,36,7,14,19],dsl:10,vector:[20,27,35,12],adapt:[7,9,27,36],reader:[9,1,13,16,32,5,18],got:[13,1,36],washer:12,forth:10,linear:20,barrier:20,situat:[32,27,10,21,1],free:[7,13,20,12],standard:[20,10,11,1,29,32,8],ncpu:30,println:[27,10,1],mousemovegener:12,quickinstal:7,"__subclasses__":[31,4,22],kit:10,acrobat:7,uiuc:27,puzzl:4,angl:20,openssh:7,mvc:29,isn:[20,10,0,29,2,27,32,34],subtl:[20,27],onto:20,bite:1,rang:[10,0,29,31,4,22,32],perfectli:12,gradi:27,setlayout:29,hoop:8,independ:[20,27,29],wast:[32,4,29],restrict:[2,10,8,21,29],"__tojava__":10,unlik:[32,27,11,1],alreadi:[20,10,11,1,29,2,27,16,7,35],messag:[20,10,12,1,29,32,7],wasn:27,getmemb:6,thick:4,agre:32,primari:[3,27,11,1,31],hood:10,brillig:10,vendingmachinetest:12,rewritten:[13,18],"__implement":34,spinach:19,top:19,sometim:[20,10,0,13,27,36,7,8],stack:29,rsrc:29,exponenti:[20,19],necessarili:[13,0],master:[10,27,12],too:[20,10,1,13,27,33,18,8,19],similarli:10,ndiff:6,consol:[10,1],tool:[9,10,11,1,12,2,4,13,7,29,27,14],lower:20,getcontentpan:29,somewhat:2,technic:13,trek:21,silli:27,target:[10,29],keyword:[32,10,4,29],provid:[20,32,10,0,1,12,29,4,16,27,11,36,7,21,8,19,34],"__onlyon":21,tree:[10,1],second:[32,10,11,29,27,22,16,34,21,8],"final":[20,10,0,1,29,2,31,27,13,35,7,8,19],project:[20,9,10,1,2,31,27,13,17,7,14,35],matter:[13,20,27,11,4],shapefactori:4,foamedmilk:19,fashion:[32,27,8],mind:[13,21,1,6],mine:7,raw:32,aforement:20,"__main__":[21,1,29,10,32,6],seen:[20,32,10,11,29,12,2,4,16,34,8],seem:[20,10,1,12,14,4,32,27,34,8],seek:[27,12],seminar:2,innerclass:10,realm:[16,20],respectjavaaccess:10,terrif:10,person:[7,10],latter:[20,10],especi:[20,27,28,10,32,17],thorough:10,alreadyopen:29,staticinnerclass:10,client:[27,0,1,12,2,34,36],alldecor:19,thoroughli:2,wherebi:12,simplifi:[7,21,10,4],shall:[10,11,1],bruce:7,glob:[10,1],object:[20,9,10,11,1,12,32,8,29,4,22,16,27,34,5,35,36,31,21,14,19],what:[1,2,3,4,6,7,8,9,10,11,12,13,16,18,19,20,27,21,29,32,34,36],messeng:[9,27,11,12,5,6],regular:[32,10,1,19],letter:0,phase:[20,27,8],coin:11,sub:6,tradit:20,simplic:[20,31,10,12,32],don:[20,9,10,27,29,2,3,4,22,32,13,33,34,36,7,8,18],simplif:10,pythoninterpreterset:10,doc:7,flow:[13,10],doe:[20,10,11,1,12,8,29,4,32,27,0,21,14,28,34],bash_profil:7,dummi:11,declar:[32,1],wildcard:10,itemslot:12,notion:34,dot:10,marvel:32,has_kei:[27,4,12,30],endear:10,visitor:[20,9,27,1,29,31],"__str__":[31,21,11,22,12],random:[20,27,29,31,4,22],particip:7,syntax:[10,1,27,32,5,21,8],"2008v1":7,involv:[20,27,15,21,16,7],despit:27,layout:[2,13,10],acquir:29,menu:[7,15,4,19],explain:[34,8,1,4],configur:[9,10,29,12,13,27,22,7,37],restaur:19,sugar:8,theme:11,busi:31,"__call__":[21,11,8],python3pattern:[7,14],oct:10,edict:31,cappuccino:19,vener:7,stop:[27,1],on_mouseup:29,report:[7,1,35],rosettacod:11,bat:10,bar:[13,3,21],isopen:29,emb:[32,10],baz:3,choru:34,"public":[20,10,1,2,27,13],twice:[1,29],bad:[13,4],steam:19,black:[9,1,29],fair:11,decoratortalk:8,elimin:[10,27],mandatori:20,result:[20,32,10,11,1,29,27,16,6,8,19,35],respons:[9,27,0,12,32,11,35,19],fail:[27,10,8,1,12],hash:[16,32,12],charact:[10,4],hammer:27,best:[20,10,2,32,13,7,8],brazil:2,awar:[27,10,4,29],said:2,alsum:27,databas:21,hgrc:7,red3d:35,discoveri:[20,27],figur:[2,13,10,27,30],emptor:18,simplest:[20,21,10,1,29],awai:[20,27,19,12],getkei:10,approach:[20,9,10,29,12,31,4,16,27,36,7,21,8,19],attribut:[2,8,10,5,20],accord:[16,27,1],extend:[16,31,27,1,4],xrang:10,weak:32,extens:[7,13,10,27],lazi:[21,34,12],preprocessor:8,backgroundcolor:29,rtti:[9,27],aparat:27,protect:[10,34,1,29],accident:[20,27],expos:[27,36],ill:27,pitt:8,against:[31,10,8,27],sketch:13,logic:[20,29,19],countri:11,com:[20,10,1,12,13,27,16,7,8,35],con:19,compromis:[9,19],kwd:21,notifyobserv:29,elf:31,trunk:[7,9,10],sai:[20,32,10,0,29,12,13,31,27,22,16,11,6,7,8],"2nd":10,diff:7,guid:[7,9],assum:[7,32,27,21],duplic:[20,6],light:10,testsynchron:29,three:[20,10,12,31,8,19],been:[20,10,29,12,2,27,32,13,34,18,21,8],chrysanthemum:31,much:[20,10,27,1,29,2,3,4,32,13,31,7,8,18],interest:[20,10,1,29,2,27,21,8],basic:[20,9,10,1,12,2,4,32,16,27,34,36,29,8,19],evolut:[20,27],"__doc__":6,"__len__":10,quickli:[10,12],life:29,deeper:[27,10,4],getval:10,xxx:30,isfunct:6,dave:16,alreadyclos:29,bookstor:2,ugli:[27,36],exception:[32,10],ident:[27,36,21,12],occam:20,gnu:1,servic:[2,13],properti:10,commerci:[13,10],air:[4,12],employ:2,calcul:[11,29],aid:32,vagu:20,dizzi:20,enlev:20,seconddigit:12,player:29,kwarg:[5,6],tediou:[10,29],sever:[27,10,4,12],valgen:10,quand:20,perform:[20,10,11,1,12,31,4,22,27,0,29,8,19],suggest:[20,27,1,13,21,32,7],make:[1,2,4,5,6,7,8,9,10,11,12,13,14,17,19,20,27,22,21,28,29,31,32,34],format:[2,7,32,13],who:[27,28,29,2,13,17,7,14],complex:[9,10,11,1,29,4,6,8],descend:1,complet:[20,10,1,12,27,34,7,29,8,35],inheritor:29,blue:29,listperform:37,hand:[20,32,27,11,29,13,4,16,21,8],fairli:[20,27,1,29,10,22],nix:10,rais:[2,27,12],garlic:19,refin:[10,14,27],techniqu:[27,3,21,4,16,31],qualif:10,jframe:[10,29],kept:[2,1],thu:[20,32,10,11,1,12,4,22,16,27,0,8,19],getbyt:35,inherit:[20,9,10,11,1,12,29,4,32,27,0,21,19],runtimeexcept:[16,12],academia:11,shortli:[32,1],greatest:[20,27],thi:[0,1,2,3,4,5,6,7,8,10,11,12,13,14,15,16,18,19,20,27,22,21,28,29,31,32,33,34,35,36],programm:[20,9,10,0,1,12,2,21,32,34,36,8],everyth:[10,29,30,2,27,32,13,18,8],isomorph:20,left:[20,27,29,13,31,15,6,7],agon:2,identifi:[7,32,10,4],setcolor:[35,29],just:[20,10,11,1,12,30,2,29,4,22,32,13,34,5,6,7,21,27,8,19,18],"__dict__":[21,5,6,29],kdiff3:7,yet:[32,10,1,29,13,27,16,6,18,21,35],languag:[20,9,10,11,1,12,3,4,32,27,33,6,8,28],previous:[27,4],easi:[20,10,1,27,22,32,7,19],had:[20,32,10,11,1,12,2,31,27,16,35,8,19],keyset:[10,27],spread:[4,22],prison:35,falter:1,els:[20,10,1,12,30,27,32,6,7,21,35],functionobject:11,explanatori:10,gave:[2,27],applic:[20,9,10,0,12,4,34,7,8],fortun:27,larman:36,mayb:[13,14,1],background:29,elabor:27,shadow:20,unten:8,readlineconsol:10,apart:20,maxval:10,specif:[20,10,11,1,12,4,16,27,34,7,29,14],arbitrari:[32,27],nudg:0,hunt:[27,35,29],manual:[27,22],doubledispatch:27,singl:[10,11,29,12,13,4,22,32,27,34,7,21,8],night:[2,10],ocbox:29,unnecessari:[10,34,4,12],singletonpattern:21,underli:20,www:[20,32,10,11,1,12,27,16,7,29,8,35],right:[20,10,29,13,2,27,32,18,6,7],old:27,deal:[10,27,36,22],printf:32,interp:10,somehow:[10,34,27],percentag:2,intern:[16,27,1,4],borg:21,"5b0":10,indirect:27,successfulli:[7,27,1],atteint:20,txt:[35,12],htmlhelp:7,bottom:[32,11],subclass:[9,10,12,4,27,19],suffici:10,condit:[9,11,1,12,4,32,35],foo:[13,3,10,8,21],paintcompon:29,sensibl:[4,22],steamedmilk:19,confer:[2,13,27],speak:[2,34],promot:[2,27],mazegen:35,pylist:10,post:[7,8],"super":[21,29],meyer:35,trustworthi:6,unpackag:10,obj:[16,32],getparametertyp:1,slightli:[9,12,1,29,5,8],py2float:10,surround:[32,27,35,29],simul:[20,9,27],commit:[7,14],produc:[20,10,27,1,12,2,31,4,22,16,13,36,8],makeobstacl:4,dilemma:[31,27],thermostat:10,javac:10,curiou:18,basenam:6,"float":10,encod:22,bound:[2,31,10,27],mocha:19,down:[10,11,1,29,4,35,19],creativ:[2,27,17],weightvisitor:27,coverag:[14,28],cappuccinodecafwhip:19,wrap:[10,11,29,27,16,21,8,19],opportun:27,clearchang:29,javax:10,testdumpclassinfo:10,east:35,accordingli:13,wai:[20,10,11,1,12,30,2,31,29,4,32,13,34,5,36,7,21,27,8,19,28],frustrat:10,support:[9,10,1,12,2,3,4,32,27,17,7,29],"class":[0,1,4,5,6,8,9,10,11,12,16,35,20,21,22,27,29,31,32,34,19,36,37],avail:[20,10,11,1,2,27,32],width:[35,29],reli:[16,27,5],editor:[7,13],analysi:20,head:[20,11],medium:20,repetiti:15,form:[20,9,27,1,29,2,15,4,16,32],offer:19,altogeth:[20,27],forg:1,heat:12,hear:1,dead:35,heap:[27,34],hashtabl:[],"true":[27,1,12,10,4,32],analyst:27,"6dd415847e5cbf7c":7,entryexit:8,pragu:27,setsuccess:11,maximum:[20,32],tell:[10,11,1,12,4,32,27,7,35],minor:29,absenc:1,fundament:[11,20,0,1,32],trim:27,classif:20,featur:[20,10,1,2,15,27,32,33,7,8],setxi:35,semicolon:32,classic:[27,12],howdi:10,request:[20,11,35,12],"abstract":[20,9,27,4,36],visitabledecor:27,drive:0,exist:[16,27,0,4,6],desir:[10,11,5,27,29],download:[2,7,10,16,29],mold:[27,36],check:[10,1,12,29,4,32,27,6,7,21,14],assembl:19,pipe:10,mindview:10,tip:7,refactor:[9,27,1,28],tij:37,test:[20,9,10,11,1,12,27,18,6,7,29,14],tie:20,appetit:20,smell:12,realiti:10,getsizetupl:29,notif:[20,29],intend:[2,10,1],felt:10,intent:[16,20,31],consid:[20,9,10,11,1,27,22,34,35,8,19],bitbucket:[7,9,14,28],receiv:[10,8,29],longer:[10,13,27,32,8,19],furthermor:11,intimaci:27,ignor:[21,27,1],fact:[20,27,1,29,10,32,21,8],time:[20,32,10,0,1,12,2,29,4,16,13,11,35,21,27,8,19],push:7,backward:[35,28],osx:[7,30],concept:[20,9,10,0,11],chain:[9,11,12],skip:1,consum:[10,5,19],focus:4,invent:[10,34],cafelattedecaf:19,objcount:1,milk:19,row:[29,12],decid:[27,12,29,31,10,4,32,34,19],depend:[20,27,29,12,10,4,28,14],decim:32,intermedi:2,certainli:[20,27,29,12,10,4,34,19],decis:[13,16,35,32],jvm:10,text:[9,12,2,15,32,13,6,7,35],jtextarea:10,isinst:[16,30],sourc:[20,10,1,12,2,27,13,7,29,35],string:[9,10,11,1,12,4,32,27,29,35],brazillian:2,onlyon:21,"fa\u00e7ad":[9,36],broadli:27,word:[10,11,1,12,0,36,8],exact:[27,4,12,22],jdk:[10,1,29],level:[20,27,1,29,4,32,6,8],did:[32,10,6],die:35,gui:[0,4,29],evalpap:22,launchpad:[2,13],item:[29,10,4,12,22],team:[2,7,28,9],quick:[9,10,1,32,7,19],round:34,dir:[10,1,6],prevent:[9,27,1,29,4,34],plaincap:19,core:[7,32,10],htm:35,compens:20,sign:[7,10,14],bondag:8,cost:[20,19,12],cafelattewetwhip:19,run:[20,9,10,0,1,12,27,32,11,6,7,29,8,35,34],corba:10,appear:[20,10,11,1,12,13,8,29,4,32,27,21,14,28],filler:27,scaffold:4,current:[20,32,10,1,12,27,16,14,35],suspect:4,newalgorithm:11,shapefact2:4,deriv:[27,12,1,29,10,4,32,34],cappuccinodri:19,gener:[1,2,4,6,7,8,9,10,11,12,14,16,35,20,21,22,26,27,28,29,31,32,34,36],satisfi:[20,27,11,12,34],modif:[27,8,19],chainlink:11,address:34,along:[20,32,10,1,12,27,16,34],stem:10,teacher:17,wait:[29,10,27,12],box:[9,10,1,29,4],messengeridiom:5,fenc:20,alti:29,shift:6,clip4:27,queue:11,behav:[10,8,27,12],extrem:[7,27,10,8,1],commonli:[10,27],trashtyp:27,semant:[32,1],regardless:[27,34],repositori:2,extra:[32,29,27,1,19],activ:[13,31,27,4],modul:[32,3,10,8,29],prefer:13,toarrai:10,leav:[27,29],visibl:10,codemark:6,instal:[9,10,1,29,27,7],forefront:1,gsum:27,anounc:7,newslett:20,prove:[27,8],univers:[20,4],visit:[31,10,27],recycleap:27,subvers:10,everybodi:29,live:10,handler:29,msg:32,scope:32,checkout:[7,14],testid:1,chapter:[32,10,11,1,2,8,27,16,13,33,35,37,14,19],testpyutil:10,afford:11,peopl:[20,27,1,28,2,31,32,13,17,7,8],claus:[32,29,4,12],clue:27,visual:[7,9,29,13],appendix:2,rigid:10,oop:[20,27,1,29],examin:[10,27],alexand:16,jlabel:10,effort:[9,10,11,1,2,27,17],easiest:[7,9,10,31],fly:31,graphic:[35,1,29,4],prepar:8,dmitri:21,battl:[31,4],focu:[13,3,27],addel:35,flowlayout:10,problemsolv:11,can:[1,2,4,5,6,7,8,9,10,11,12,13,14,15,16,17,19,20,27,22,21,29,31,32,34,35,36],purpos:[20,27,11,4],problemat:16,claim:11,encapsul:[20,9,27,11,12,4],stream:10,predict:8,wrapped_f:8,explos:27,backslash:[32,10],topic:[2,32,21],heard:27,chih:21,abort:[1,6],proxydemo:34,recycl:[9,27],unfortun:10,occur:[20,27,11,1,12,13,4,22,29],pink:29,alwai:[20,27,0,1,28,10,32,21,14],killanddismemb:4,variou:[20,10,11,1,12,31,4,22,27,0,19],get:[18,9,10,11,1,12,32,2,31,20,27,22,16,13,6,36,7,29,8,19,17],ping:10,write:[20,9,10,0,1,12,2,4,32,16,13,11,6,29,27,34],anyon:[2,35],actual:[20,32,10,11,1,12,4,22,16,27,34,6,29,8],pure:[10,12],"0x00798900":21,parameter:27,ensconc:10,map:[10,12,31,27,32,35],product:[13,32,10,1],dialog:10,max:29,thermostatdai:10,spot:[13,4],usabl:12,wantmor:12,inputb:12,inputc:12,mac:7,inputa:12,mymethod:29,aop:8,mai:[20,32,10,11,1,12,2,29,4,16,13,33,35,7,21,27,19],underscor:[13,32,21],data:[9,10,11,29,12,4,32,16,27,5,21],grow:33,goal:[20,9,10,1,12,2,27,32,8,35],my_login:7,practic:32,johnson:20,divid:1,explicit:[20,11,8,22],cafelattewhip:19,inform:[10,11,1,12,30,8,29,4,22,32,27,5,7,21,14,35],"switch":[27,11,35,34],preced:19,combin:[9,10,11,29,2,22,19],block:[13,6],callabl:[8,29],talk:[7,20,10,27],vike:32,extractor:[14,1],dojo:17,comfort:[1,36],countobserv:29,greenhouselanguag:10,brain:[32,11],lst:10,codemanag:6,still:[20,10,27,29,12,2,4,32,13,6,7,14],stringlist:27,dynam:[20,9,10,11,29,31,4,22,32,27,34,8,19],rosetta:17,group:[20,27,11,29,2,31,32,6,7,35,17],thank:[9,28],polici:0,jim:[27,11],platform:[9,10,30],window:[9,10,30,13,15,7,14],curli:32,borgsingleton:21,truli:[],ddtrash:27,non:[20,10,1,2,27,32],within:[20,27,29,12,10,4,32,8],halt:1,halv:32,sysconf_nam:30,alist:7,initi:[20,10,0,29,12,4,27,34,7,21,14,35],sorter:27,underneath:7,typedbinmemb:27,pyinteg:10,aesthet:27,therebi:1,half:34,javaclassinpython:10,now:[20,10,1,12,31,4,27,35,7,8,28],discuss:[20,27,35],introduct:[2,7,8,32,9],term:[20,27,11,1,12,34,36,8],name:[20,10,0,1,12,13,8,29,4,22,32,27,34,5,6,7,21,14,19],ppr:27,getweapon:31,didn:[20,32,14,1],oliv:19,phyast:8,separ:[20,10,0,1,12,31,4,32,27,11,7,29,34],rock:22,cafemochadecafwhip:19,pizza:19,jmap:10,compil:[20,10,11,1,29,27,32,34,6,18,8],domain:10,replac:[10,11,1,13,31,32,8],individu:[7,27,35,19],arg3:8,continu:[27,1,12,10,32,6],contributor:[2,9,14,28],parsetrash:27,significantli:8,begun:20,year:[16,20,27,1],happen:[20,10,27,1,12,2,4,13,29,8,19],dispos:10,troll:31,shown:[20,27,11,31,10,4,32,19],accomplish:[21,29,10,32,27,34,36],cafemochawhip:19,"3rd":[16,19],space:[27,13,10,32,34,6,35],profit:[2,10],antoin:20,profil:10,stuff:13,internet:[1,35],returnstr:10,factori:[20,9,27,12,4,36],earlier:27,"goto":27,state:[20,9,27,11,29,12,4,32,34,21],getcwd:1,argu:[13,3,16,8,20],argv:6,lab:27,org:[10,11,1,29,14,32,28,7,8],"byte":[10,35],care:[13,32,27,4],reusabl:[16,27],couldn:[27,11,1],yarko:[7,14,28],synchron:29,junit:1,recov:27,thing:[20,10,11,1,29,2,27,22,32,13,34,7,8],place:[32,10,27,1,12,2,4,16,13,5,17,7,29,8,19,18],greenhous:[37,10],principl:[20,9,27,1,12,36],typic:[20,27,11,1,12,32,0,5,8,19],think:[20,32,10,11,1,29,2,27,22,16,7,8,19],frequent:27,first:[20,9,10,0,1,12,32,29,4,22,16,27,34,6,36,7,21,8,19,35],origin:[10,1,29,14,27,16,35,8,19],directli:[27,0,1,2,10,32,21],carri:[27,11,12],onc:[20,10,29,27,6,7,8,19],arrai:[20,27,12,10,4,32,36,35],getcost:19,crib:30,yourself:[10,12,2,27,32,7],submit:1,ring:10,open:[10,0,1,12,2,27,13,6,7,29],size:[2,29,10,1,19],given:[27,0,12,29,10,4,34,35],sheet:[7,1],stuck:1,teardown:1,caught:12,adjac:29,plastic:27,gnureadlin:10,circl:[4,12],showdigit:12,white:[9,27,1,29],conveni:[21,29,13,10,4,34,19],cite:35,pocoo:[14,28],simionato:8,cope:27,copi:[27,12,29,2,34,6,7],specifi:[10,1,12,2,4,32,7],broadcast:12,newcolor:29,enclos:19,enigma:27,changeavail:12,holder:27,than:[20,32,10,11,1,29,13,31,4,22,16,27,34,8,19],png:7,serv:[20,4],setattr:21,instanc:[21,1,12,10,22,19],applet:0,bintyp:27,were:[27,1,12,10,4,32,8],posit:[35,29],stub:34,surrog:[11,36,19,34],seri:8,fork:7,coconut:32,nicer:[7,36,29],svnroot:10,argument:[20,9,10,11,1,12,4,32,27,5,29,8],ant:10,prt:10,properli:[10,8,27,22],deliv:10,breakfast:29,kevin:29,leastsquar:11,engin:[31,0,1],squar:[4,29],patternrefactor:[27,11],note:[1,4,6,7,8,9,10,11,12,13,15,16,18,19,20,27,21,28,29,32,33,34,35],forc:[20,32,10,1,29,2,4,16,34,6],ideal:10,take:[20,32,10,0,1,12,2,31,29,4,16,27,11,36,7,21,8,19,28],green:29,noth:[20,27,11,1,29,13,35],begin:[20,10,28,13,27,32,7,8],sure:[2,32,10],trace:[8,1,29],normal:[20,21,11,1,31,27,4,32],track:[27,12,29,2,34,5],price:[2,27,19,12],drinkcompon:19,beta:10,pair:[27,36],neatli:34,televis:21,latex:[7,13,14,28],synonym:20,later:[20,10,11,1,4,27,7,21,8,19],sale:2,quantiti:[29,27,21,12],addbranch:7,runtim:[9,10,11,4],parseint:29,link:[7,13,11,14],shop:[2,19],shot:[27,19],linedata:11,show:[20,32,10,11,1,13,3,15,4,16,27,6,7,21,8],cheat:7,cheap:[20,27],subprocess:10,mousetrap2test:12,concurr:[3,9],permiss:[10,1],hack:[7,14],ground:10,xml:[10,36],onli:[0,1,2,4,6,7,8,10,11,12,13,16,19,20,27,22,21,29,31,32,34,36],explicitli:[32,27,10,8,4],nexta:12,nextb:12,nextc:12,transact:20,fillabl:27,observedflow:29,enough:[10,1,29,13,27,4,7],doubleespresso:19,dict:[21,10,5,6],analyz:20,jaroslav:27,clearselect:12,startswith:6,proxy2:34,nearli:1,viewpoint:27,distinctli:12,ddaluminum:27,cannot:[20,32,10,0,12,31,27,16,21],ssh:7,afunct:8,gen:4,requir:[20,32,10,1,12,4,16,27,33,5,6,36,7,29,8,19],jtextfield:10,prime:[27,1,29],reveal:35,isemptyxi:35,aluminum:27,dramat:1,yield:[3,31,4,22],spameggssausageandspam:10,expedi:1,pynam:10,makec:36,through:[20,32,10,11,1,12,2,29,4,22,16,13,34,21,27,8],where:[20,10,11,29,12,2,4,22,32,18,5,6,7,27,8,35],vision:2,summari:[9,10,27],wiki:[10,11,28,27,7,8],caller:[27,4],pydictionari:10,booch:27,cafelattewet:19,testcas:[],rmi:34,purest:11,concern:[27,8,1],timeit:10,detect:[27,22,35,30],charat:10,review:[7,9,8,1],enumer:[16,6,12,22],label:[10,14,28],getattr:[21,34],trashbinset:27,between:[20,10,1,12,27,34,7,29],"import":[20,10,0,1,12,2,3,4,22,32,13,5,6,31,29,27],item2:22,across:[10,4],aslist:10,docutil:[],assumpt:[31,27],parent:[7,10],tup:10,screen:[27,0,1,29],inflex:19,cycl:32,pythoncardapp:29,findminima:11,come:[20,10,1,12,2,29,4,32,27,6,7,21,35],readlin:[10,27,12,35],tug:7,ispubl:1,pepperdew:19,quiet:27,contract:2,inconsist:8,improv:[9,27,28,12,2,21,32,13,7],somecondit:1,minima:11,color:[13,35,29],overview:[7,9,27],unittest:[27,10,1,12],period:32,dispatch:[9,27,29,31,4,22],yearli:27,colon:[32,10],exuperi:20,consider:[9,27,19],mousetrap:12,coupl:[20,9,27],games2:4,west:35,rebuild:10,mark:[20,32],appframework:0,quiesec:12,reflex:20,astonish:20,spare:32,emphas:[13,27,10,4],further:[9,10,1,29,13,3,27,32,8],trantabl:12,cafelatteextraespresso:19,findal:6,repres:[32,27,12],"__eq__":[22,12],former:[16,21],those:[20,10,1,29,2,4,22,32,27,5,17,7,8],newbyt:35,sound:[2,8],myself:[8,17],tostr:10,keygen:7,trick:[10,5,27],cast:[10,27,36],invok:[27,1,10,22,32,7,8,19],outcom:[4,22],familiar:[7,16,27],invoc:19,anytim:[13,29],advantag:[16,21,10,27,12],stdout:10,canon:[9,15],ivi:7,worri:[2,13,16],equal:[20,27,10,1,32],endswith:[10,6],eras:[1,4],myapp:0,couplet:27,shutil:6,fame:27,"__init__":[32,10,0,1,12,35,29,4,22,16,27,11,5,6,36,21,8,19,34],develop:[20,9,10,1,2,13,7],author:[11,29],fulful:11,same:[20,32,10,11,1,12,13,29,4,22,16,27,34,21,8,19],trip:2,binari:7,html:[10,28,13,8,27,32,6,7,14],testrunn:[],customize1:0,pai:[2,10,27],document:[10,1,29,13,8,32,7,14],pollut:20,number_of_processor:30,nest:[32,21,4,19],foam:19,someon:[7,14,29],driven:[37,9,1,12,35],mani:[10,1,12,2,29,27,32,7,21,8,19],extern:[9,27,1,12,6],tosynch:29,tradition:[32,1],hummingbird:29,appropri:[20,10,11,1,12,31,4,32,27],macro:[9,11,8],facad:36,connector:20,pep8:13,gameenviron:4,without:[20,9,10,27,1,29,2,4,32,16,13,7,8,19],model:[20,31,27,29,19],dimension:[36,12],arrays2:32,"23f":27,execut:[9,10,11,1,29,4,22,32,27,7,8],excel:16,thermostatnight:10,rest:[20,10,0,1,12,2,4,27,6,7,8],recyclea:27,aspect:[20,10,8,4,29],recycleb:27,touch:[31,27],monei:[2,12],flavor:11,speed:10,pythondecoratorlibrari:8,except:[27,0,1,12,10,22,8],littl:[20,10,1,12,27,32,7,8,35],blog:7,pile:20,treatment:27,exercis:[9,10,11,1,12,31,29,4,27,0,17,36,21,19],addmouselisten:29,real:[10,11,35,34],around:[20,27,1,29,13,31,4,32,34,5,35,8,19],todolist:[14,28],"0079ef2c":21,repaint:[35,29],grid:29,pop:[10,27],amp:[3,1],rununittest:1,presum:[27,4],returnarrai:10,mod:35,saniti:1,colorbox:29,stranger:20,chainofrespons:11,integ:[32,10,29],benefit:[10,29,2,27,32,13,34,19],either:[20,10,11,29,22,32,19],output:[10,0,1,12,13,8,21,32,28,7,14,19],margherita:19,manag:[20,10,11,12,29,31,21],fulfil:[20,11,34],tulach:27,satisfactori:27,adequ:[20,32],constitut:29,nonzero:1,regina:19,slice:10,mood:12,chronicl:20,boxobserverpythoncard:29,definit:[27,0,1,2,10,32,34,8],evolv:[13,20,10,27,1],exit:[35,8,1,29,6],inject:[10,8],complic:[27,34,1,19],ratcount:35,refer:[20,27,1,12,2,4,22,32,13,34,35,7,21,19,18],power:[7,21,10,8,27],cappuccinoextraespressowhip:19,garbag:[10,1],inspect:[7,6],typedbin:27,standpoint:1,"__name__":[10,11,1,29,31,4,22,32,6,8,19],"throw":[16,10,1,12,4],comparison:[10,4,12],central:[16,27,12],greatli:27,strategypattern:11,firstnam:7,panna:19,splitlin:6,currentlin:35,stand:[20,31,27,34],neighbor:29,act:[20,27,11,8],other:[0,1,2,4,7,8,9,10,11,12,13,14,15,16,19,20,27,22,21,29,31,32,34,35,36],routin:34,effici:27,lastli:[16,10],quietli:10,"75f":19,strip:[27,19,1,12,6],counterintuit:27,your:[0,1,2,4,6,7,9,10,11,12,13,15,16,19,20,27,22,21,29,30,31,32,34],wustl:27,log:29,aren:[13,20,36,1,32],commenttag:6,overwrit:6,hee:34,stealth:10,interfac:[20,9,10,11,29,12,31,4,32,16,27,34,36,19],low:[20,27],lot:[20,10,1,12,2,27,32],pollin:31,strictli:27,machin:[7,9,12,30],unam:10,lang:[10,27],programmat:19,tupl:[32,10,5,22],bundl:36,regard:20,vendingmachin:12,stepanov:16,conciev:12,"0076aa3c":21,functor:11,mice:12,conclus:16,faster:[10,1],notat:10,tripl:32,algorithm:[20,9,27,11,29,4,16,35],impenetr:1,possibl:[20,10,27,1,12,2,4,32,13,34,35,21,8,19],"default":[27,11,1,29,30,10,7,35],asynchronizedmethod:29,grasp:32,embed:10,expect:[20,10,27,22,32,18,8],gone:[10,11],creat:[0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,19,20,27,22,21,28,29,31,32,34,35,36],certain:[27,10,15,19,12],whatihave2:36,strongli:32,intro:14,file:[9,10,0,1,12,13,15,27,32,11,6,7,29,14,35],jargon:31,rearrang:16,cream:19,incorrect:16,again:[2,27,10,1,32],setval:10,googl:7,want:[20,32,10,11,1,12,2,29,4,22,16,13,34,5,36,7,21,27,8,19,28],tradeoff:19,my_decor:8,compel:[20,10,6],event:[20,10,0,35,29],idiom:[20,9,11,29,24,34,7],valid:[10,1],compet:22,jset:10,you:[0,1,2,4,5,6,7,8,9,10,11,12,13,15,16,18,19,20,27,22,21,29,30,31,32,34,35,36],getdescript:19,interactwith:4,architectur:[2,20,10,29],check_result:6,inevit:27,registri:10,sequenc:[20,32,10,11,12,27,16],tbin:27,vocabulari:20,pool:21,reduc:[1,19],assert:[36,1,12,4],multiplejython:10,opennotifi:29,directori:[10,1,13,27,6,7,14],descript:[10,1,12,27,6,7,21,14,19],hello:[10,8,12],gradient:20,mass:29,potenti:[20,29],escap:12,cpu:30,represent:12,all:[0,1,2,4,6,7,8,10,11,12,13,16,18,19,20,27,22,21,29,31,32,34],dist:10,skeleton:34,messi:[27,22,30],lack:[10,1],dollar:12,sanitycheck:1,monti:32,abil:[20,29,2,31,13,8],follow:[20,10,27,1,12,2,4,22,32,13,34,5,7,29,8,19],research:[2,10,36],hashmap:[10,27,12],edong:7,"__cmp__":[10,12],init:0,program:[20,9,10,11,29,1,12,32,2,15,4,22,16,13,6,21,27,8],hasattr:30,rstrip:6,contentpan:10,"case":[32,10,11,1,29,2,4,22,16,27,34,5,21,8,35],liter:[32,22],straightforward:[20,10,27],fals:[27,10,6,12],checkin:[7,14],faq:7,util:[32,10,1,29,16,7],defvar:7,candid:[16,20],mechan:[9,27,0,13,22,16,32,11,8,34],fall:[8,1,30],veri:[20,9,10,11,1,29,2,4,22,32,13,7,21,8,35],bottleneck:10,bruceeckel:[7,16,10,20,1],lisp:8,list:[20,9,10,0,1,12,2,8,4,22,32,27,11,5,6,7,29,14,28],signific:[13,16,27,1,35],emul:29,small:[2,13,20,19],everth:15,dimens:29,pyobject:10,tea:19,eas:[27,19,12],tee:34,tex:7,zero:[10,1],pressur:1,design:[20,9,10,11,1,12,13,31,29,4,32,16,27,34,6,36,21,8,19],pass:[10,11,1,12,31,29,4,22,32,27,34,5,36,7,21,8,19],whene:34,val2:32,new_f:8,deleg:[27,34,21],brien:27,ntotal:27,advanc:[2,11],abl:[20,10,0,1,12,2,4,22,16,13,11,27,35,34],brief:32,overload:[32,10,27],version:[10,27,29,12,2,8,4,22,32,13,36,7,21,14,18],succinct:[10,8],fillbin:27,method:[20,9,10,0,1,12,31,29,4,22,32,27,11,6,36,21,8,19,34],contrast:32,movement:[20,27,11],hasn:[27,29],full:[7,32,10,34,6],themselv:[20,32,29],variat:[20,27,36,21,12],sophist:[32,10,1,4],rlock:29,shouldn:[7,11],excess:12,demet:20,rudimentari:32,modifi:[10,27,1,12,2,31,29,4,22,32,13,7,21,8],valu:[10,1,12,27,22,32,5,36,8],search:[9,27,0,1,32,7],upcast:[27,4],ahead:[32,1],vegetarian:19,popen:10,observ:[20,9,27,1,12,21,29],prior:27,amount:[27,11,1,12,15,10],pick:27,action:[20,9,10,11,12,4,27,34],introductori:[9,10,2,32,7,8],scurri:35,pytupl:10,via:[2,7,10,27,22],shorthand:10,primit:[10,27],transit:[9,12],"while":[20,10,11,1,12,2,27,32,34,35],readili:20,filenam:[27,6,35],inappropri:[10,1],ystart:35,famili:[27,11,22],establish:[16,32,27,1,12],jbutton:10,select:[20,9,10,11,29,12,13,27,7,19],kittiesandpuzzl:4,aggress:32,twa:10,proceed:27,distinct:[20,21,11,12,10,27,34],tackl:27,two:[10,0,1,12,2,31,29,4,22,32,27,34,6,36,21,8],bizarr:8,getweight:27,autonom:35,machinediscoveri:30,taken:[13,27,10,1,4],showtot:12,singletonmetaclass:21,more:[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,19,20,27,22,21,28,29,31,32,34,35,36],flaw:1,door:12,mydialog:10,apologet:8,reconfigur:31,convinc:1,ddcardboard:27,flag:[10,29],stick:8,particular:[20,32,10,11,1,12,2,4,16,27,34,35,7,21,19],known:27,compani:[2,10],cach:10,dictat:2,none:[21,10,29,1,12],pyprog:1,valuabl:27,dev:7,histori:[7,9,8,6],testdemo2:1,remain:[16,27,12],caveat:[18,1],learn:[20,27,2,32,13,7],returnchang:12,statedemo:34,dee:34,def:[32,10,0,1,12,30,31,29,4,22,16,27,11,5,6,36,21,35,8,19,34],prompt:7,scan:13,challeng:35,share:[2,7,21],accept:[7,16,10,27,31],fiddl:34,minimum:[7,32,10,29],explor:16,statet:12,phrase:1,magenta:29,condemn:27,huge:19,cours:[20,10,1,28,2,4,27,34,36,19],newlin:32,awkward:10,secur:[10,8],rather:[32,10,1,29,30,13,31,4,16,27,34,36,8,19],anoth:[20,10,11,29,12,31,4,32,27,34,7,21,8,19],mouseact:12,myratno:35,ish:[13,32],smalltalk:[20,29],simpl:[9,10,0,1,12,4,32,27,34,36,7,29],css:[14,28],distro:10,plant:27,resourc:[9,1,29,36,14,35],algebra:16,variant:27,reflect:[9,10,27,1],tabl:[9,12,31,22,16,32,34,37],associ:[32,10,27],"short":[32,30],waysid:1,ani:[20,32,10,27,1,12,2,29,4,16,13,34,35,7,21,8,19],confus:[27,29,31,32,36,8],mousemovelist:12,ambigu:10,caus:[20,10,1,12,31,4,27,7,29],flwr:31,setchang:29,egg:[32,21],sysctl:30,help:[20,27,29,2,3,13,34,17,7],mazework:35,soon:1,held:[20,34,12],pythondialog:10,paper:[27,22],scott:20,cyan:29,hierarchi:[20,27,11,31,4,22,34],taxonomi:[20,9],implicitli:[20,32,10,4],paramet:11,latt:19,style:[11,1,28,13,12,32,14],conjugategradi:11,alli:17,late:[27,19],rapidli:[10,29],runal:12,pythondecor:8,might:[20,10,11,1,29,2,4,22,16,27,8,35],currentst:12,wouldn:[27,1,4],good:[20,10,1,12,2,27,32,13],"return":[32,10,11,1,12,30,31,29,4,22,16,27,34,5,6,36,21,8,19,35],martelli:21,ttbinlist:27,framework:[20,9,10,0,1,12],somebodi:[2,7],complain:32,bigger:[10,12],whatiw:36,intricaci:4,customize2:0,hook:29,solver:11,instruct:[7,1],refresh:[14,6],easili:[20,10,11,1,12,27,22,5,36,21],achiev:[21,10,8,27,19],compris:8,getmodifi:1,found:[20,27,1,14,35,7,8,19],max_num:27,button:[7,10,4],harm:[9,27,12],weight:27,hard:[13,16,27,4,31],idea:[20,10,11,12,2,8,4,13,34,17,7,27,14],procedur:27,realli:[20,21,11,12,10,32,27,36],finish:[20,10,1,12,7,8],iter:[20,9,10,1,12,4,32,16,27,26],windowadapt:29,ddpaper:27,http:[10,11,1,12,8,27,28,7,29,14,35],todo:[9,10,28,6,7,14],orient:[20,27,11,10,4,32,8],flower:[9,29,31],safeti:[32,1],classvariablesingleton:21,differentreturn:32,miss:[20,27,10,6],setsiz:[35,29],publish:[2,27,10,1],princ:20,footnot:[20,10,11,1,12,27,21,14],gameelementfactori:4,print:[0,1,2,4,5,6,8,9,10,11,12,13,14,35,27,22,21,29,31,32,34,19],qualifi:[32,1],lutz:32,proxi:[20,9,10,12,21,16,34,36,19],hashset:10,reason:[20,10,11,1,12,2,4,32,27,34,36,8,19],base:[20,10,0,1,12,2,31,29,4,22,32,27,11,7,21,35,34],put:[20,9,10,27,1,12,2,8,4,32,13,5,6,7,21,14,17],teach:[2,9,1,17],bash:1,basi:[1,29],thrown:27,thread:[7,35,29],script:[13,9,10,11,32],struggl:20,revolutionari:1,perhap:[27,1,13,31,10,4,36],pythonsw:10,ascher:32,trashsort:27,lifetim:34,clump:5,assign:[7,8,10,5,32],major:[32,8],notifi:29,obviou:[16,27],blush:27,feel:[7,13,20,1],articl:[3,15],lastnam:7,number:[20,10,11,1,12,30,13,29,27,22,32,34,35,36,7,21,8,19],placehold:12,sayhello:8,done:[10,11,1,29,2,4,32,13,7,14,28],least:[20,10,1,27,32,7],colorboxestest:29,stabl:10,actionperform:10,fanci:12,gpl:10,razor:20,differ:[20,32,10,11,1,12,8,4,22,16,27,34,6,31,7,29,14,19],decoupl:[16,9,11,29],printstacktrac:[27,1],interact:[31,10,4,36,22],tove:10,construct:[16,10,8,1],addfactori:4,paint:[13,35],expand:[7,34],statement:[10,11,1,12,4,32,27,34,29,8],scheme:[31,27,29],syrup:19,store:[8,1,12],itempairgen:22,imperfect:13,option:[20,11,29,2,32,6,7,19],relationship:20,behind:[20,34],checklist:20,shapefactory1:4,shapefactory2:4,part:[20,9,10,0,1,29,2,8,27,25,32,23,24,11,6,7,14,19,35],pars:[32,9,27,22],consult:2,off:[20,10,29,2,15,27,32],eventu:[20,1],tortoisehg:7,albeit:[20,32,10,27],kind:[20,32,10,1,12,2,31,4,22,16,27,34,29,8],plop:27,whenev:[20,27,0,29,4,5,7,8],remot:34,gotten:12,remov:[20,27,12,29,2,16],kapow:10,pythoninterpret:10,reus:[20,27,0,12,10,11,21],getconstructor:[10,27],toward:[20,1],danc:34,builder:[],runsawai:12,comput:[10,27],nastyweapon:4,ardent:1,requisit:1,"null":[34,1,12,35],sell:2,imagin:[27,4],wilson:8,built:[20,9,10,11,1,29,2,27,32,34,7],equival:[32,27,10,1,29],jythonc:10,self:[20,32,10,0,1,12,35,31,29,4,22,16,27,11,5,6,36,21,8,19,34],violat:10,typediter:16,also:[20,32,10,11,1,12,2,29,4,16,13,35,17,37,7,21,27,8,19,28],bgboxobserv:29,build:[9,10,0,1,32,2,31,4,16,13,36,7,27,14],mouseev:29,brace:32,distribut:[7,13,10,4],exec:10,blackboard:35,eater:31,lighton:10,reach:[20,11,35],mixtur:19,addobserv:29,most:[20,10,0,1,29,2,4,27,11,5,8,19],plai:[31,27,4],cygwin:7,eaten:31,thidiscuss:11,maco:30,alpha:10,amaz:[10,8,35],fileread:35,bug:[7,31,27,1],clear:[2,20,8,29,12],cover:[2,13,33,0,1],roughli:[1,12],"_shared_st":21,ext:[14,28],clean:[32,27,10,1],jython2:10,xstart:35,latest:7,mousetrap2:12,mousetrap1:12,tri:[10,11,27],test3:[10,1],flowergen:31,canvaswidth:35,particularli:[13,32,27,22],uncov:10,font:[2,10],fine:[27,4],find:[20,10,11,1,2,4,32,13,7,27,8,19],impact:[27,8],less:[20,27,1,13,5,8,19],solut:[20,10,11,1,12,29,4,22,27,21,19],pyutil:10,templat:[9,10,0,12,2,4,32,16,13,11,27,8],darkgrai:[35,29],shapefact1:4,affirm:[32,1],unus:20,cappuccinodecaf:19,express:[20,10,1,13,22,32],entry_exit_class:8,swing:10,nativ:[7,10],mainten:[27,19],wateroff:10,ineffici:29,doubli:29,cyclic:12,stl:[16,10,11],common:[20,10,1,12,2,4,32,27,34,17,29],wrote:[10,1],commod:27,cafemochawetwhip:19,pyexcept:10,adopt:1,creator:[7,11,28],cleverli:13,startup:[7,10],potent:10,emac:[7,9,14],bare:29,aluminumbin:27,arg:[27,1,29,10,32,7,21,8,35],close:[29,1,12,35],horizont:35,cafelatt:19,analog:32,dwarf:31,expert:[13,11],someth:[20,10,11,1,12,2,31,27,22,32,13,17,36,29,8,19],conditionc:12,conditionb:12,conditiona:12,weakli:[],won:[10,29,2,27,32,13],mutex:29,autogener:[14,28],experi:[2,20,10,8,1],nope:1,birkenfeld:7,altern:[20,10,1,3,27,8],signatur:[32,10],str:[32,29],numer:[0,5,11,22],hasnext:[16,27,10,1,12],complement:20,sole:11,isol:[20,27,11,4],statemachin:[9,12],disallow:4,cachedir:10,len:[11,35,1,29,6],solv:[20,10,11,1,12,3,27,22,32,34,36,31,29,35],extraespresso:19,both:[20,10,29,13,4,22,32,27,34,35,7,21,8,19],"__instanc":21,last:[31,10,0,27],hyperlink:14,arraylist:[10,27],alon:[27,29],undetermin:0,context:[9,11,14],forgotten:15,commandpattern:11,whole:[27,11,1,12,2,10,29],load:[27,10,4,36,7,35],randomli:[31,1],simpli:[20,32,10,0,29,12,31,27,16,28,34,5,36],point:[20,27,11,1,12,30,2,29,4,32,13,7,21,8,35,18],schedul:[31,10],sweep:1,arbitrarili:34,header:7,templatemethod:0,param:10,linux:[7,14,30],throughout:[20,27,0,1,13,4],simpler:[20,21,1,29,27,34,8],identif:27,java:[9,10,1,12,32,4,22,16,27,34,6,18,29,8,35],dum:34,due:1,empti:[35,29],sinc:[20,10,11,1,12,4,32,27,34,29,8,19],mercuri:[7,9,14,28],newinst:[27,1],pushnew:7,strategi:[9,11,6],addison:[27,11],versa:32,execfil:10,clariti:[13,19],imag:[13,29],great:[2,18,10,20],coordin:35,changeimp:34,understand:[20,10,12,13,27,32,21,8],demand:[2,32,34,1,4],makedir:6,fillablevisitor:27,look:[20,10,11,1,12,13,8,29,4,32,27,34,31,7,21,14,19,28],packag:[32,27,10,1,12],frozen:29,buildtabl:12,getquant:12,decrquant:12,ought:12,behavior:[20,10,11,29,12,27,22,16,36,21,8,35],error:[27,1,12,13,10,6,29],"__hash__":12,anonym:[9,27,37],fum:10,everyon:[28,29,2,32,13,17],errmsg:1,pack:10,argin5:10,argin4:10,pound:32,argin1:10,argin3:10,argin2:10,readi:[2,7,27,0,35],petal:29,itself:[20,10,11,12,13,27,8,35],makea:36,coroutin:[3,9],attach:[13,9],chase:4,decor:[9,27,29,8,21,16,14,19],guido:28,minim:[20,1,29],boxwidth:29,belong:2,on_openbackground:29,shorter:10,read:[20,9,10,0,1,12,30,2,3,27,32,6,29,8,35],conflict:7,higher:7,cappucino:19,vertdir:35,optim:[10,27],painless:27,wherea:[32,10,11,27,12],ponder:20,setbackground:35,user:[9,10,29,12,2,4,16,27,7,21],cardboardbin:27,focal:20,recent:[10,1],propon:27,task:[7,13,29],lib:32,eleg:[20,27,21,32,34,8],openobserv:29,entri:[13,8,10,14,35],localarrai:29,propog:29,parenthes:32,restfil:[10,6],testpythontojavaclass:10,chees:12,expens:[27,34],elev:[27,12],academ:1,imit:[7,32],propos:[7,20],explan:10,pyfloat:10,valueof:27,obscur:20,shape:[27,4],world:[20,10,11,8,1],"67f":27,dumpclassinfo:10,dirlist:11,cut:[27,36,29],indexof:[10,27],mydecor:8,branch:[7,9,27,14,35],snag:29,correcton:2,appli:[20,27,12,1,29,32,36,8],input:[3,0,12],subsequ:[32,12],brainstorm:20,bin:[7,27,10,1],tomap:10,vendor:[31,27],transpar:[10,1,19],big:[32,8],intuit:10,game:[4,29],alias:34,verion:7,bit:[32,10,29,2,27,4,16,34,8],characterist:0,formal:[32,8],success:[20,10,11,1,27,16],nextstat:12,signal:10,resolv:27,fluf:13,collect:[20,21,11,1,12,27,36],"__new__":21,sizeabl:19,javabean:10,encount:[27,1,29,10,4,16],"0076daac":21,often:[20,10,11,1,12,2,31,15,27,32,13,5,17,36,29,8,19],acknowledg:[20,32],creation:[20,9,10,27,1,12,2,29,4,32,16,13,21,8],some:[0,1,2,3,4,5,7,8,10,11,12,13,14,17,35,20,22,27,28,29,30,32,36],back:[20,10,11,1,12,2,27,29,8,35],global:[10,1],understood:[10,1],wxpython:29,mirror:20,sprint:2,surpris:[32,8],mousepress:29,syndrom:27,rien:20,scale:[3,10,1],chocol:19,mousemov:12,though:[21,27,8,1,29],per:[20,29,19,12,32],usernam:7,substitut:[32,8],mathemat:[11,22],larg:[10,12,2,3,27,33],market:31,fornam:[27,1],reproduc:2,norvig:29,cgi:[32,27],previou:[27,12,2,4,8,19],patient:10,lose:[31,10,27,22],agreement:10,viabl:20,step:[20,32,10,1,2,4,16,27,7],initialst:12,subtract:20,impos:[16,12],sellimaginaryproduct:31,constraint:[20,32,27,12,2,16,8],materi:[2,13,10,17],memori:1,libero:12,modal:10,cappuccinodrywhip:19,gamma:20,plan:10,predat:31,repair:27,"__future__":[31,4,22],pythonpath:32,dispens:12,oreilli:32,fowler:[27,8],rapid:10,"caf\u00e9":19,ensur:[7,20,34,1,6],chang:[20,9,10,0,1,12,13,31,29,4,27,33,34,6,36,7,21,8,19],artifici:1,occupi:32,inclus:[20,32],institut:1,spam:[32,21,29],valuminum:27,question:[7,20,10,27,12],fast:[13,32,10,1],custom:[7,10,0,27,19],clip3:27,clip2:27,clip1:27,arithmet:35,includ:[20,32,10,29,1,12,15,27,16,28,17,7,21,8,19],suit:1,forward:[20,10],jarrai:10,blueprint:[2,7],larri:27,hawaiian:19,sc_nprocessors_onln:30,quiescent:12,translat:[20,9,10,27,1,12,2,4,22,16,13,29,14,35],delta:6,line:[9,10,0,1,12,8,15,27,32,11,5,6,7,29,14,35],talli:27,info:[27,5,29],concaten:32,consist:[20,27,1,29,13,4,32,19],balabanov:21,strang:[32,4,12],jpython:10,priveleg:10,fillrect:[35,29],pythoncard:29,similar:[20,10,11,1,12,27,32,34,29,8],toomuchaccess:1,parser:27,chao:1,doesn:[20,10,29,12,2,8,27,22,32,13,6,36,21,14],lectur:17,"char":[10,35],home:[7,10],cafe:19,blackboxtest:1,titl:[10,29],water:10,windowi:7,appendic:13,intvalu:10,tbinlist:27,"_imag":13,mouseclick:29,getbound:35,cappuccinoextraespresso:19,nice:[2,7,32],draw:[0,4,35,22],getdeclaredclass:1,pythoninterpreterget:10,state_d:34,topydictionari:10,est:20,eval:[4,22],itemavail:12,pricevisitor:27,svn:10,jc2:10,vice:32,downcast:27,actionlisten:10,entryset:10,normpath:6,discrimin:32,jpanel:29,greenhousecontrol:10,mindlessli:27,karma:[2,13],far:[20,32,27,1],java2pi:10,showmsg:32,prototyp:[20,9,10,27],code:[0,1,4,6,7,8,9,10,11,12,14,15,16,17,35,20,27,29,31,32,34,19,37],partial:32,unclassifi:27,scratch:[10,8],tclone:27,"__getattr__":[21,34],edu:[27,8],benevol:2,privat:[21,0,1,29,10,7],successfuli:10,elsewher:13,friendli:1,send:[2,32,10,34,27],granular:1,becam:1,paperscissorsrock2:22,sens:[20,10,11,1,4,32,27,5,8,19],ajout:20,sent:10,func2:8,func1:8,cheapli:[10,27],mainstream:8,sausag:21,mous:[29,12],testdemo:1,electron:[2,13],alik:2,volum:[2,13],whatius:36,makeschang:12,kitti:4,recip:9,magic:21,counterproduct:27,knight:34,proxyadapt:36,hive:21,"try":[20,10,11,1,29,13,27,36,7,8,35],session:12,mousetraptest:12,myfunct:32,pleas:[2,7,14,18],boxobserv:[1,29],"__metaclass__":21,readabl:32,natur:[27,1,29,13,32,8,35],verbiag:32,elisp:7,annot:[8,12],jump:8,slithi:10,binset:27,singletondecor:21,changeneighbor:29,odd:[34,19],click:[7,13,29],append:[10,11,1,29,32,6,7],compat:28,index:[9,10,11,13,27,5,7,14],getclass:[16,31,10,27,12],compar:[7,27,10,11,1],espresso:19,access:[21,1,29,4,32,34,8],deleteobserv:29,runuculu:31,mouseadapt:29,whatev:[13,27,1],ibid:20,absolut:32,getmethod:[10,27],closur:8,let:[10,1,12,13,4,27,8,19],becom:[20,32,10,1,12,27,16,29,19],implicit:8,remark:[32,10,27],talent:2,convers:10,musser:16,larger:[27,28],technolog:[13,1],makeb:36,orgpattern:27,scatter:27,staticmethod:[21,8,4,36,6],earli:[13,18,10,1],nameless:10,ratcanmov:35,evalrock:22,chanc:11,win:[31,10,22],app:29,foundat:[9,23],"_updat":6,pyton:10,fillablecollect:27,hennei:20,"boolean":[10,27,12,35],notenough:12,limb:8,newimp:34,puriti:10,fee:10,from:[0,1,2,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,27,22,21,29,30,31,32,34,35,36,37],sysconf:30,zip:[7,6],commun:[2,10,35],doubl:[9,10,31,27,4,32,22,21],addtrash:27,whatihave3:36,next:[10,11,1,12,4,16,27,21,35],implic:19,few:[5,19],camera:2,usr:[7,1],stage:[20,27,19],remaind:[7,9,27,14],sort:[20,32,10,11,27,16],clever:20,src:7,tplus1:8,impress:[10,27],train:2,bufferedread:35,iii:[9,25],starter:35,account:[7,1,19],chdir:1,retriev:[],when:[20,10,11,1,12,2,31,4,22,32,18,34,35,36,7,29,27,8,19],critic:10,thin:4,meet:[31,27,12],fetch:[27,29],aquamac:7,proof:27,control:[20,9,10,11,29,12,13,4,32,27,34,7,21],cafemochawet:19,process:[20,32,10,0,1,12,13,4,22,16,27,11,7,8,19],lock:[2,8],high:[20,27],tag:[13,4,12],trashvisitor:27,csum:27,onlin:[13,29],kevlin:20,delai:[10,12],friendlier:7,comedi:32,georg:7,shapenamegen:4,sig:10,feta:19,subdirectori:[27,10,1,6],instead:[20,10,11,1,12,4,22,27,7,29,8,19],sin:10,stock:7,overridden:[32,27,0,1,12],pyarrai:10,hazard:11,callback:[27,11,29],rmtree:6,multipl:[9,10,11,29,13,31,27,22,32,7,21],"120dpi":7,cheaper:20,physic:35,alloc:1,drop:27,essenti:[20,27,11,1,10,32],seriou:1,correspond:[27,5,1,19],element:[20,27,1,12,10,32,8],issu:[13,20,27,21],allow:[20,10,11,29,12,31,4,27,0,8,28,34],subtyp:27,horizdir:35,espressodecor:19,move:[20,10,11,1,12,2,27,13,35,7,29,14,28],evolutionari:27,comma:32,bunch:27,perfect:[2,13,27,20],outer:[21,10,36,1,29],chosen:[2,29],settitl:29,gnomesandfairi:4,newsgroup:7,decaf:19,criterion:29,tst:1,typemap:27,rat:[9,35],factor:[20,32,10,1],greater:10,"__getitem__":10,handl:[20,32,27,0,14],auto:7,spell:2,dai:[2,10],ctor:27,devel:7,dat:27,mention:[2,27,11,1,4],snake:32,front:[9,34,19],strive:27,multiprocess:3,somewher:[7,4,29],anyth:[20,10,1,29,2,27,13,8],edit:[7,9,27,16,32],tran:12,quest:20,trap:12,isclass:6,batch:32,reserv:1,newtonsmethod:11,psum:27,flair:13,subset:[27,19],chung:21,tolist:10,spoken:27,transitionb:12,transitionc:12,nodecor:19,"static":[20,10,1,12,4,32,27,6,36,21,19],"_delta":6,whet:20,our:[10,8,27],patch:[7,29],transitiont:12,special:[27,10,4,32,34,7],out:[20,9,10,27,1,12,30,2,29,4,22,32,13,7,21,8,18],variabl:[7,32,21,12],matt:8,contigu:29,cwr:35,dongwoo:7,categori:[20,8,29],texliv:7,suitabl:10,rel:27,merg:[7,9,14],metaclass:[21,8],clone:[7,27],red:[35,29],clarifi:2,insid:[10,1,12,4,32,27,36,7,29,8],sortintobin:27,manipul:[16,10],standalon:7,dictionari:[10,12,4,22,32,5,36,14],tempt:34,releas:[29,1,12],embarrass:1,indent:[13,32,6],could:[20,10,11,1,12,2,29,4,32,27,34,5,21],ask:[20,10,29,4,16,27,35,7,19],membership:27,david:[20,32],length:[27,12,1,29,13,10,35],enforc:1,outsid:[32,27,10,4],distinguish:[27,10,14,1],south:35,os_walk_comprehens:6,qualiti:[20,1],scene:34,echo:[],date:10,set:[9,10,0,1,12,2,29,4,22,32,27,11,6,36,7,21,8,19],flyweight:12,newsingleton:21,facil:2,redund:11,cafemochaextraespressowhip:19,prioriti:7,"long":[10,27,2,4,32,13,34,7,21,8,19],start:[20,9,10,0,1,29,30,2,27,22,13,7,21,8,35],unknown:[27,22],licens:[2,9,10,21,17],isassignablefrom:1,mkdir:10,system:[20,10,11,1,12,30,2,31,15,4,22,13,7,27,35,18],wrapper:[10,27],overwhelm:7,which:[0,1,2,3,4,5,6,7,8,10,11,12,13,15,16,19,20,27,22,21,29,31,32,34,35],termin:[32,11,1,35],prong:27,shell:[7,32,10],rsa:7,exit_on_clos:[10,29],slider:4,rst:[2,7,14,6],exactli:[32,10,27,19],readlinelib:10,haven:[13,27],priveledg:[],cpython:10,embodi:20,split:[6,29],see:[0,1,2,4,6,7,8,10,11,12,14,16,18,19,20,27,21,29,32,34,36,37],structur:[20,9,10,11,1,12,27,16,32,34,35,19],bee:[31,34,29],bind:[2,27,22],steer:35,imho:32,aggreg:27,isstat:1,clearli:[20,27,19,1,12],have:[0,1,2,4,6,7,8,10,11,12,13,15,16,17,18,19,20,27,22,21,28,29,31,32,34,36],cohes:[20,27],need:[0,1,2,4,5,7,8,10,11,13,14,17,19,20,27,22,21,28,29,31,32,34,36],north:35,turn:[20,10,1,12,2,27,32,34,35,29,14,19],gentli:8,lightgrai:[35,29],smallest:[27,19],min:29,rout:20,rmic:34,mix:27,discret:10,sei:1,frontmatt:14,linda:16,tymciurak:7,uppercas:0,entry_exit:8,unless:[2,34,1,6],clash:27,awt:10,minimasolv:11,discov:[20,9,27,1,30,13,4,7],rigor:1,textui:[],mactex:7,why:[20,27,8],changealgorithm:11,wikic:27,gather:20,stronger:32,face:27,inde:[27,10,21,8,1],realiz:[16,20,27,1,32],bui:2,michel:8,determin:[32,27,11,12,4,22,16,35],gettotalcost:19,occasion:1,constrain:1,inexpens:27,gain:2,statemachine2:12,dbm:12,mainloop:29,connect:[20,21,11,29,12,10,27],bring:[20,10,2,27,32,8,35],debat:13,trivial:[27,10,1,12],anywai:[13,32,11],pythoncardprototyp:29,redirect:[21,10,1],textual:29,locat:[10,11,1,12,27,7,14],nois:1,createbox:29,hadn:12,winner:31,jar:10,mug:19,should:[20,32,10,11,1,12,13,3,4,16,27,35,7,29,8,19],restructur:[2,7,6,13,9],suppos:[27,1,29,10,4,32,8],esqu:32,disciplin:8,inhabit:31,local:[20,27,29,2,7,19],hope:[20,14,17],overidden:12,contribut:[2,7,28,13,9],espinc:27,ludicr:27,convert:[10,0,12,29,16,14],disagre:6,autom:[27,1,12,13,15,10],regularli:[27,19],piecewis:11,bean:10,increas:1,applicationframework:0,triangl:4,extract:[27,10,1,6],enabl:[10,8],organ:[2,7,27,20,1],bisect:11,coplien:[27,11],grai:29,whatiuse2:36,integr:[32,27,11,1,29],contain:[20,9,10,29,12,4,32,16,27,6,36,7,21],grab:27,ddglass:27,view:[13,29],conform:19,"0079e10c":21,frame:[10,35],knowledg:[32,1,4],popen2:30,displai:[32,10,8,1,6],temporarili:10,troubl:[7,32,10],py2int:10,syntact:31,polymorph:[9,27,31,4,22,32],statu:27,wire:[27,21],dlg:10,correctli:[7,1],pattern:[20,9,10,11,1,12,31,29,4,16,27,25,6,36,7,21,8,19,34],boundari:[7,10],misus:[20,27],tend:[20,32,27,1],favor:20,written:[32,11,1,29],japplet:0,progress:[7,8,14],email:[7,20],pazzaglia:16,bed:29,kei:[27,12,31,10,22,32,36,7,19],p2j:10,itertool:[26,9],job:[2,32,27,0],entir:[20,10,29,27,32,8],cafelattedecafwhip:19,addit:[10,1,12,2,27,32,34,7,29,8],exclaim:32,boxheight:29,admin:13,invulner:27,loveandtheft:8,etc:[27,0,2,4,22,18,11,7,8,19],admit:[20,27],succeed:11,equat:8,section:[20,10,31,27,4,33,36,7,14],freeli:[16,10,1],comment:[7,32,10,1],make_fil:6,interp2:10,"0076c54c":21,simpleclass:32,wall:35,guidelin:[13,27],arriv:27,chmod:10,walk:[20,10,1,6],vend:[9,12],incess:28,respect:27,labor:20,quit:[10,1,12,13,4,32,8,19],htmldiff:6,decent:20,obstacl:4,compon:[16,29,10,27,19],treat:[27,10,1,12],nextto:29,immedi:[27,8,1,35,4],inneradapt:36,bulk:[13,27],espressoconpanna:19,togeth:[10,11,27,32,34,36],present:[20,27,1,12,10,36,19],multi:12,main:[10,0,1,29,2,27,32,7,35],plain:[7,19],align:32,harder:10,defin:[20,32,10,0,1,12,29,4,16,27,5,21,8,19],aarrgggh:35,decept:10,howev:[20,32,10,11,1,12,13,31,29,4,16,27,34,5,35,36,7,21,8,19],cafemocha:19,htmlbutton:10,layer:[20,19],almost:[20,10,29,31,32,8],site:[2,27,11],motiv:[2,9,10,20,1],prose:13,incom:2,revis:27,cafemochadecaf:19,whatihav:36,bolder:1,insight:[20,27],began:[20,1],classpath:[32,10,1],cross:[2,13,10],member:[27,1,29,2,31,22],python:[1,2,4,6,7,8,9,10,11,12,13,14,15,18,19,20,27,22,21,28,29,30,32,33,34],tendenc:27,fill:[10,27],infer:32,difficult:[20,10,12,2,27,32,19],competit:29,detect_cpu:30,original_new:21,denot:32,expans:[10,12],drink:19,upon:[31,10,8,27],effect:[27,11,1,12,29,4,22,36,21,19],coffe:[9,19],handi:29,issuccess:11,tribut:22,pdf:[2,7,13,9],canva:35,php:29,misappl:27,pull:[7,27,10,14,6],closenotifi:29,center:10,albin:27,firstli:19,weapon:31,well:[20,10,1,29,2,27,13,5,35,8,19],difflib:6,numerical_integr:11,thought:[20,27,11,28,21,16],scissor:22,weblog:8,exampl:[0,1,2,4,6,7,8,9,10,11,12,13,14,19,20,27,22,21,28,29,31,32,34,35,36,37],command:[9,10,0,1,15,32,11,6,7],setq:7,choos:[9,10,11,1,2,4,27,7,14,19],breaker:20,usual:[20,10,0,1,27,32,5,8],test1:[10,1],ccolor:29,test2:[10,1],test4:10,flesh:10,hybrid:10,heavili:[16,27],skill:11,simultan:[7,27],gliffi:13,web:[2,32],penchant:32,newbrain:11,field:[10,12,1,29,13,32],bell:[10,27],makefil:[10,14,1,28],knew:1,proxydemo2:34,add:[1,2,4,6,7,8,10,11,12,13,14,15,17,19,20,27,22,21,29,31,32,34,35],jython_hom:10,wet:19,collis:35,smart:[10,34,12],match:[31,27,11,22,29],confront:21,jython:[9,10,14],royalti:[2,10],elementat:35,fate:27,sumvalu:27,piec:[20,21,27,6],arguabl:[10,27],testa:1,camelcas:13,testb:1,know:[10,1,29,2,8,27,22,13,7,14],press:[32,10],redesign:27,height:[35,29],recurs:[27,11,4],insert:[32,21,27,6],trash:[20,9,27],resid:32,like:[20,32,10,11,1,12,2,31,4,22,16,13,34,35,17,7,29,27,8,19,28],lost:[10,27],incred:32,paperbin:27,necessari:[27,0,1,12,10,32,34,36,7],martin:[27,8],resiz:[32,0],boxdesc:29,page:[7,9,11,8,32],poor:27,sum:[32,27],trashbin:27,captur:[10,8],suppli:10,phenomena:29,cafemochaextraespresso:19,growth:19,"export":[7,10],superclass:10,flush:1,proper:[10,27,12],guarante:[7,12],peter:29,librari:[9,10,11,1,29,30,16,32,5,36],simple2:32,tmp:1,"__setattr__":21,trust:1,lead:20,developerguid:14,avoid:[7,20,27],doublevalu:27,slide:17,overlap:29,jeremi:35,itemnotavail:12,troup:32,getnam:[27,1],mode:[2,7,10,6],hinder:32,weslei:[27,11],slower:[20,10],investig:35,usag:[20,9,27,1],facilit:[27,29],host:[2,7],arg1:[32,8],although:[20,10,27,1,2,4,13,5,7,8],offset:29,beneath:0,panel:29,about:[20,9,10,27,1,12,30,2,8,4,22,16,13,35,36,7,14,19,32],quarter:12,rare:20,column:29,purist:27,javaclass:10,mindviewinc:[],bridg:10,constructor:[10,0,1,12,29,4,32,27,21,8],wxcommandev:29,"0076b7ac":21,own:[20,10,29,1,12,2,15,4,22,32,27,33,34,6,7,21,14,19,35],fillov:35,bashrc:10,automat:[9,10,11,1,12,13,15,4,32,27,34,5,6,36,7,29,28],guard:20,getpric:12,awhil:20,rectifi:[27,8],pitfal:32,forget:27,mere:10,leverag:10,prozac:12,val:[32,21,10,27,29],transfer:[9,5,12],inner:[9,10,1,29,27,36,37,21,8],transitiona:12,maze:[9,35],stai:[20,27,11],arg2:[32,8],"function":[9,10,11,1,12,32,3,29,4,22,16,27,5,31,7,21,8],mailer:7,imatix:12,pythontojavaclass:10,subscrib:20,bodi:[32,27,11,8],measur:13,kungfugui:4,highest:7,eat:31,count:[32,1,12],made:[10,12,29,13,27,28],cleanup:1,newval:27,whether:[10,11,12,29,2,27,35],wish:[10,1,19],scroll:10,dynatrash:27,distract:10,record:35,below:[7,10,11,29,19],limit:[32,10,8,21],testfil:6,trepid:8,otherwis:[20,27,11,1,29,2],problem:[20,32,10,11,1,12,3,29,4,22,16,27,34,36,31,21,8,19],jdialog:10,evalu:12,"int":[27,12,1,29,30,10,14,35],dure:[10,1,12,2,27,16,34,8],twist:27,implement:[20,9,10,11,1,12,31,4,32,27,34,35,36,29,8,19],decorator_function_with_argu:8,eric:[34,29],probabl:[20,10,11,29,13,27,22,32,34,5,8],typemapadapt:27,nonetheless:8,entry_exit_funct:8,detail:[20,9,27,11,29,30,31,21,7],virtual:[27,0,12,31,4,32,34,7],preinstal:7,book:[20,9,27,0,1,2,8,4,32,13,11,17,36,31,7,21,14,35,18],lookup:[31,22],futur:[2,10],rememb:[32,10,27,22],bazzar:13,repeat:[20,11,29,4,7,19],star:21,fulli:32,multipledispatch:22,cafelatteextraespressowhip:19,singleton:[20,9,21,36,12],lightoff:10,vein:8,typenum:27,experienc:32,sphinx:[9,28,2,13,7,14],interp1:10,came:[16,20,27],indirectli:27,rule:[20,9,10,1,13,32],getreturntyp:1,portion:1,klass:[21,29]},titles:["Building Application Frameworks","Unit Testing & Test-Driven Development","Introduction","Coroutines & Concurrency","Factory: Encapsulating Object Creation","Messenger/Data Transfer Object","Comprehensions","Developer Guide","Decorators","Python 3 Patterns, Recipes and Idioms","Jython","Function Objects","StateMachine","Book Development Rules","ToDo List","A Canonical Form for Command-Line Programs","Iterators: Decoupling Algorithms from Containers","Teaching Support","A Note To Readers","Decorator: Dynamic Type Selection","The Pattern Concept","The Singleton","Multiple Dispatching","Part I: Foundations","Part II: Idioms","Part III: Patterns","Generators, Iterators, and Itertools","Pattern Refactoring","Contributors","Observer","Discovering the Details About Your Platform","Visitor","Quick Python for Programmers","Python 3 Language Changes","Fronting for an Implementation","Projects","Changing the Interface","Table-Driven Code: Configuration Flexibility"],modules:{},descrefs:{},filenames:["AppFrameworks","UnitTesting","Introduction","CoroutinesAndConcurrency","Factory","Messenger","Comprehensions","DeveloperGuide","PythonDecorators","index","Jython","FunctionObjects","StateMachine","Rules","ToDo","CanonicalScript","Iterators","TeachingSupport","NoteToReaders","Decorator","PatternConcept","Singleton","MultipleDispatching","Part1","Part2","Part3","GeneratorsIterators","PatternRefactoring","Contributors","Observer","MachineDiscovery","Visitor","QuickPython","LanguageChanges","Fronting","Projects","ChangeInterface","TableDriven"]})

Up to file-list src/Jython.rst:

@@ -10,66 +10,48 @@ Jython
10
10
   	   that the material can be used to introduce Java programmers to
11
11
	   Jython.
12
12
13
This chapter looks at the value of crossing language boundaries. It is often
14
advantageous to solve a problem using more than one programming language, rather
15
than being arbitrarily stuck using a single language. As you'll see in this
16
chapter, a problem that is very difficult or tedious to solve in one language
17
can often be solved quickly and easily in another. If you can combine the use of
18
languages, you can create your product much more quickly and cheaply.
13
Sometimes it's easier and faster to temporarily step into another
14
language to solve a particular aspect of your problem.
19
15
20
The most straightforward use of this idea is the *Interpreter* design
21
pattern, which adds an interpreted language to your program to allow
22
the end user to easily customize a solution. If the application user
23
needs greater run time flexibility, for example to create scripts
24
describing the desired behavior of the system, you can use
25
*Interpreter* by creating and embedding a language interpreter into
26
your program.
16
This chapter looks at the value of crossing language boundaries. It is
17
often advantageous to solve a problem using more than one programming
18
language; as you'll see, a problem that is very difficult or tedious
19
to solve in one language can often be solved quickly and easily in
20
another. By combining languages, you can create your product much more
21
quickly and cheaply.
22
23
One use of this idea is the *Interpreter* design pattern, which adds
24
an interpreted language to your program to allow the end user to
25
easily customize a solution. If the application user needs greater run
26
time flexibility, for example to create scripts describing the desired
27
behavior of the system, you can use *Interpreter* by creating and
28
embedding a language interpreter into your program.
27
29
28
30
In Java, the easiest and most powerful way to do this is with *Jython*
29
31
[#]_, an implementation of Python in pure Java byte codes. As you will
30
32
see, this brings together the benefits of both worlds.
31
33
32
*Interpreter* solves a particular problem -- that of creating a
33
scripting language for the user. But sometimes it's just easier and
34
faster to temporarily step into another language to solve a particular
35
aspect of your problem. You're not creating an interpreter, you're
36
just writing some code in another language.
37
38
Interpreter Motivation
39
=======================================================================
40
41
Remember that each design pattern allows one or more factors to change, so it's
42
important to first be aware of which factor is changing. Sometimes the end users
43
of your application (rather than the programmers of that application) need
44
complete flexibility in the way that they configure some aspect of the program.
45
That is, they need to do some kind of simple programming. The interpreter
46
pattern provides this flexibility by adding a language interpreter.
47
48
The problem is that developing your own language and building an interpreter is
49
a time-consuming distraction from the process of developing your application.
50
You must ask whether you want to finish writing your application or create a new
51
language.  The best solution is to reuse code: embed an interpreter that's
52
already been built and debugged for you. The Python language can be freely
53
embedded into your for-profit application without signing any license agreement,
54
paying royalties, or dealing with strings of any kind. There are basically no
55
restrictions at all when you're using Python.
56
57
For solving Java problems, we will look at a special version of Python called
58
Jython. This is generated entirely in Java byte codes, so incorporating it into
59
your application is quite simple,  and it's as portable as Java is. It has an
60
extremely clean interface with Java: Java can call Python classes, and Python
61
can call Java classes.
34
Jython is generated entirely in Java byte codes, so incorporating it
35
into your application is quite simple, and it's as portable as Java
36
is. It has an extremely clean interface with Java: Java can call
37
Python classes, and Python can call Java classes.
62
38
63
39
Because Jython is just Java classes, it can often be "stealthed" into
64
40
companies that have rigid processes for using new languges and
65
41
tools. If Java has been accepted, such companies often accept anything
66
42
that runs on the JVM without question.
67
43
68
Python is designed with classes from the ground up and is a truly pure object
69
oriented language (both C++ and Java violate purity in various ways). Python
70
scales up so that you can create very big programs without losing control of the
71
code. Java projects have been quickly created using Jython, then later optimized by
72
rewriting sections of the Jython code that have profiled as bottlenecks into Java.
44
The Python/Jython language can be freely embedded into your for-profit
45
application without signing any license agreement, paying royalties,
46
or dealing with strings of any kind. There are basically no
47
restrictions when you're using Python/Jython.
48
49
Python is designed with classes from the ground up and provides pure
50
support for object-oriented programming (both C++ and Java violate
51
purity in various ways). Python scales up so that you can create large
52
programs without losing control of the code. Java projects have been
53
quickly created using Jython, then later optimized by rewriting into
54
Java sections of the Jython code that have profiled as bottlenecks.
73
55
74
56
Installation
75
57
=======================================================================
@@ -123,7 +105,7 @@ See: http://wiki.python.org/jython/Readl
123
105
Scripting
124
106
=======================================================================
125
107
126
One very compelling benefit of using a dynamic language on the JVM is
108
One compelling benefit of using a dynamic language on the JVM is
127
109
scripting.  You can rapidly create and test code, and solve problems
128
110
more quickly.
129
111
@@ -157,21 +139,21 @@ benefits of the JVM. The total runtime o
157
139
faster because of its rapid startup time; the JVM always has a delay
158
140
for startup.
159
141
160
Note that things that require much more code (and often research) in
161
Java are very quick to write in Jython. Here's an example that uses
162
a Python *list comprehension* with the **os.walk()** function to visit
163
all the directories in a directory tree, and find all the files with names
164
that end in **.java** (of course you can easily do more sophisticated things
165
like opening the file and looking for information within it)::
142
Note that things that are very quick to write in Jython require much
143
more code (and often research) in Java. Here's an example that uses a
144
Python *list comprehension* with the **os.walk()** function to visit
145
all the directories in a directory tree, and find all the files with
146
names that end in **.java** and contain the word **PythonInterpreter**::
166
147
167
     # Jython/Walk_comprehension.py
168
     import os
148
       # Jython/Walk_comprehension.py
149
       import os
169
150
170
     restFiles = [os.path.join(d[0], f) for d in os.walk(".")
171
                  for f in d[2] if f.endswith(".java")]
151
       restFiles = [os.path.join(d[0], f) for d in os.walk(".")
152
       		    for f in d[2] if f.endswith(".java") and
153
                    "PythonInterpreter" in open(os.path.join(d[0], f)).read()]
172
154
173
     for r in restFiles:
174
     	 print(r)
155
       for r in restFiles:
156
       	   print(r)
175
157
176
158
You can certainly achieve this in Java. It will just take a lot longer.
177
159
@@ -179,17 +161,35 @@ Often more sophisticated programs begin
179
161
The fact that you can quickly try things out allows you to test
180
162
concepts, and then create more refined code as needed.
181
163
164
Interpreter Motivation
165
=======================================================================
166
167
Remember that each design pattern allows one or more factors to
168
change, so it's important to first be aware of which factor is
169
changing. Sometimes the end users of your application (rather than the
170
programmers of that application) need complete flexibility in the way
171
that they configure some aspect of the program.  That is, they need to
172
do some kind of simple programming. The *Interpreter* pattern provides
173
this flexibility by adding a language interpreter.
174
175
The problem is that creating your own language and building an
176
interpreter is a time-consuming distraction from the process of
177
developing your application.  You must ask whether you want to finish
178
writing your application or make a new language.  The best solution is
179
to reuse code: embed an interpreter that's already been built and
180
debugged for you.
181
182
182
Creating a Language
183
=======================================================================
183
-------------------------------------------------------------------------
184
184
185
185
It turns out to be remarkably simple to use Jython to create an
186
186
interpreted language inside your application. Consider the greenhouse
187
187
controller example from *Thinking in Java*. This is a situation where
188
188
you want the end user -- the person managing the greenhouse -- to have
189
189
configuration control over the system, and so a simple scripting
190
language is the ideal solution.  This is often called a
191
*domain-specific language* (DSL) because it solves a particular
192
domain problem.
190
language is an ideal solution.  This is often called a
191
*domain-specific language* (DSL) because it solves a particular domain
192
problem.
193
193
194
194
To create the language, we'll simply write a set of Python classes,
195
195
and the constructor of each will add itself to a (static) master
@@ -268,21 +268,21 @@ but outside of any methods, is what make
268
268
.. note:: To run this program say ``python GreenHouseLanguage.py`` or
269
269
   	  ``jython GreenHouseLanguage.py``.
270
270
271
The constructor of each derived class calls the base-class constructor, which
272
adds the new object to the list. The **run()** function sorts the list, which
273
automatically uses the **__cmp__()** method defined in **Event** to
274
base comparisons on time only. In this example, it only prints out the list, but
275
in the real system it would wait for the time of each event to come up and then
276
run the event.
271
The constructor of each derived class calls the base-class
272
constructor, which adds the new object to the list. The **run()**
273
function sorts the list, which automatically uses the **__cmp__()**
274
method defined in **Event** to base comparisons on time only. In this
275
example, it only prints out the list, but in the real system it would
276
wait for the time of each event to come up and then run the event.
277
277
278
278
The **__main__** section performs a simple test on the classes.
279
279
280
280
The above file -- which is an ordinary Python program -- is now a
281
module that can be included in another Python program.
282
But instead of using it in an ordinary Python program,
283
let's use Jython, inside of Java. This turns out to be remarkably
284
simple: you import some Jython classes, create a **PythonInterpreter**
285
object, and cause the Python files to be loaded:
281
module that can be included in another Python program.  But instead of
282
using it in an ordinary Python program, let's use Jython, inside of
283
Java. This turns out to be remarkably simple: you import some Jython
284
classes, create a **PythonInterpreter** object, and cause the Python
285
files to be loaded:
286
286
287
287
..  code-block:: java
288
288
@@ -302,13 +302,14 @@ object, and cause the Python files to be
302
302
      }
303
303
    }
304
304
305
The **PythonInterpreter** object is a complete Python interpreter that accepts
306
commands from the Java program. One of these commands is **execfile()**, which
307
tells it to execute all the statements it finds in a particular file. By
308
executing **GreenHouseLanguage.py**, all the classes from that file are loaded
309
into our **PythonInterpreter** object, and so it now "holds" the greenhouse
310
controller language. The **Schedule.ghs** file is the one created by the end
311
user to control the greenhouse. Here's an example::
305
The **PythonInterpreter** object is a complete Python interpreter that
306
accepts commands from the Java program. One of these commands is
307
**execfile()**, which tells it to execute all the statements it finds
308
in a particular file. By executing **GreenHouseLanguage.py**, all the
309
classes from that file are loaded into our **PythonInterpreter**
310
object, and so it now "holds" the greenhouse controller language. The
311
**Schedule.ghs** file is the one created by the end user to control
312
the greenhouse. Here's an example::
312
313
313
314
    # Jython/Schedule.ghs
314
315
    Bell(7.00)
@@ -319,9 +320,9 @@ user to control the greenhouse. Here's a
319
320
    LightOff(2.00)
320
321
    WaterOff(4.45)
321
322
322
This is the goal of the interpreter design pattern: to make the configuration of
323
your program as simple as possible for the end user. With Jython you can achieve
324
this with almost no effort at all.
323
This is the goal of the interpreter design pattern: to make the
324
configuration of your program as simple as possible for the end
325
user. With Jython you can achieve this with almost no effort at all.
325
326
326
327
One of the other methods available to the **PythonInterpreter** is
327
328
**exec()**, which allows you to send a command to the interpreter. In
@@ -330,11 +331,11 @@ the above program, the **run()** functio
330
331
Using Java libraries
331
332
=======================================================================
332
333
333
Jython wraps the Java libraries so that any of them can be used directly or via
334
inheritance. In addition, Python shorthand simplifies coding.
334
Jython wraps Java libraries so that any of them can be used directly
335
or via inheritance. In addition, Python shorthand simplifies coding.
335
336
336
As an example, consider the **HTMLButton.java** example from
337
*Thinking in Java*. Here is its conversion to Jython::
337
As an example, consider the **HTMLButton.java** example from *Thinking
338
in Java*. Here is its conversion to Jython::
338
339
339
340
    # Jython/PythonSwing.py
340
341
    # The HTMLButton.java example from "Thinking in Java"
@@ -361,21 +362,23 @@ As an example, consider the **HTMLButton
361
362
    frame.size=200, 500
362
363
363
364
If you compare the Java version of the program to the above Jython
364
implementation, you'll see that Jython is shorter and generally easier to
365
understand. For example, to set up the frame in the Java version you had to make
366
several calls: the constructor for **JFrame()**, the **setVisible()** method
367
and the **setDefaultCloseOperation()** method, whereas in the above code all
368
three of these operations are performed with a single constructor call.
365
implementation, you'll see that Jython is shorter and generally easier
366
to understand. For example, to set up the frame in the Java version
367
you had to make several calls: the constructor for **JFrame()**, the
368
**setVisible()** method and the **setDefaultCloseOperation()** method,
369
whereas in the above code all three of these operations are performed
370
with a single constructor call.
369
371
370
Also notice that the **JButton** is configured with an **actionListener()**
371
method inside the constructor, with the assignment to **kapow**. In addition,
372
Jython's JavaBean awareness means that a call to any method with a name that
373
begins with "**set**" can be replaced with an assignment, as you see above.
372
Also notice that the **JButton** is configured with an
373
**actionListener()** method inside the constructor, with the
374
assignment to **kapow**. In addition, Jython's JavaBean awareness
375
means that a call to any method with a name that begins with "**set**"
376
can be replaced with an assignment, as you see above.
374
377
375
The only method that did not come over from Java is the **pack()** method,
376
which seems to be essential in order to force the layout to happen properly.
377
It's also important that the call to **pack()** appear *before* the **size**
378
setting.
378
The only method that did not come over from Java is the **pack()**
379
method, which seems to be essential in order to force the layout to
380
happen properly.  It's also important that the call to **pack()**
381
appear *before* the **size** setting.
379
382
380
383
Inheriting from Java library Classes
381
384
-------------------------------------------------------------------------------
@@ -409,24 +412,25 @@ converted into Jython::
409
412
    frame.pack()
410
413
411
414
412
**MyDialog** is inherited from **JDialog**, and you can see named arguments
413
being used in the call to the base-class constructor.
415
**MyDialog** is inherited from **JDialog**, and you can see named
416
arguments being used in the call to the base-class constructor.
414
417
415
In the creation of the "OK" **JButton**, note that the **actionPerformed**
416
method is set right inside the constructor, and that the function is created
417
using the Python **lambda** keyword. This creates a nameless function with the
418
arguments appearing before the colon and the expression that generates the
419
returned value after the colon. As you should know, the Java prototype for the
420
**actionPerformed()** method only contains a single argument, but the lambda
421
expression indicates two. However, the second argument is provided with a
422
default value, so the function *can* be called with only one argument. The
423
reason for the second argument is seen in the default value, because this is a
424
way to pass **self** into the lambda expression, so that it can be used to
425
dispose of the dialog.
418
In the creation of the "OK" **JButton**, note that the
419
**actionPerformed** method is set right inside the constructor, and
420
that the function is created using the Python **lambda** keyword. This
421
creates a nameless function with the arguments appearing before the
422
colon and the expression that generates the returned value after the
423
colon. As you should know, the Java prototype for the
424
**actionPerformed()** method only contains a single argument, but the
425
lambda expression indicates two. However, the second argument is
426
provided with a default value, so the function *can* be called with
427
only one argument. The reason for the second argument is seen in the
428
default value, because this is a way to pass **self** into the lambda
429
expression, so that it can be used to dispose of the dialog.
426
430
427
Compare this code with the version that's published in *Thinking in Java*.
428
You'll find that Python language features allow a much more succinct and direct
429
implementation.
431
Compare this code with the version that's published in *Thinking in
432
Java*.  You'll find that Python language features allow a much more
433
succinct and direct implementation.
430
434
431
435
432
436
Controlling Java from Jython
@@ -492,55 +496,61 @@ create yourself, as you can see here::
492
496
..  todo:: rewrite to distinguish python generator from above description, or
493
497
    	   choose different name.
494
498
495
Note that the **import** statements map to the Java package structure exactly as
496
you would expect. In the first example, a **Date()** object is created as if it
497
were a native Python class, and printing this object just calls **toString()**.
499
Note that the **import** statements map to the Java package structure
500
exactly as you would expect. In the first example, a **Date()** object
501
is created as if it were a native Python class, and printing this
502
object just calls **toString()**.
498
503
499
**ValGen** implements the concept of a "generator" which is used a great deal in
500
the C++ STL (*Standard Template Library*, part of the Standard C++ Library). A
501
generator is an object that produces a new object every time its "generation
502
method" is called, and it is quite convenient for filling containers. Here, I
503
wanted to use it in a **for** iteration, and so I needed the generation method
504
to be the one that is called by the iteration process. This is a special method
505
called **__getitem__()**, which is actually the overloaded operator for
506
indexing, '**[ ]**'. A **for** loop calls this method every time it wants to
507
move the iteration forward, and when the elements run out, **__getitem__()**
508
throws an out-of-bounds exception and that signals the end of the **for** loop
509
(in other languages, you would never use an exception for ordinary control flow,
510
but in Python it seems to work quite well). This exception happens automatically
511
when **self.val[i]** runs out of elements, so the **__getitem__()** code turns
512
out to be simple. The only complexity is that **__getitem__()** appears to
513
return *two* objects instead of just one. What Python does is automatically
514
package multiple return values into a tuple, so you still only end up returning
515
a single object (in C++ or Java you would have to create your own data structure
516
to accomplish this). In addition, in the **for** loop where **ValGen** is used,
517
Python automatically "unpacks" the tuple so that you can have multiple iterators
518
in the **for**. These are the kinds of syntax simplifications that make Python
519
so endearing.
504
**ValGen** implements the concept of a "generator" which is used a
505
great deal in the C++ STL (*Standard Template Library*, part of the
506
Standard C++ Library). A generator is an object that produces a new
507
object every time its "generation method" is called, and it is quite
508
convenient for filling containers. Here, I wanted to use it in a
509
**for** iteration, and so I needed the generation method to be the one
510
that is called by the iteration process. This is a special method
511
called **__getitem__()**, which is actually the overloaded operator
512
for indexing, '**[ ]**'. A **for** loop calls this method every time
513
it wants to move the iteration forward, and when the elements run out,
514
**__getitem__()** throws an out-of-bounds exception and that signals
515
the end of the **for** loop (in other languages, you would never use
516
an exception for ordinary control flow, but in Python it seems to work
517
quite well). This exception happens automatically when **self.val[i]**
518
runs out of elements, so the **__getitem__()** code turns out to be
519
simple. The only complexity is that **__getitem__()** appears to
520
return *two* objects instead of just one. What Python does is
521
automatically package multiple return values into a tuple, so you
522
still only end up returning a single object (in C++ or Java you would
523
have to create your own data structure to accomplish this). In
524
addition, in the **for** loop where **ValGen** is used, Python
525
automatically "unpacks" the tuple so that you can have multiple
526
iterators in the **for**. These are the kinds of syntax
527
simplifications that make Python so endearing.
520
528
521
The **jmap** and **jset** objects are instances of Java's **HashMap** and
522
**HashSet**, again created as if those classes were just native Python
523
components. In the **for** loop, the **put()** and **add()** methods work just
524
like they do in Java. Also, indexing into a Java **Map** uses the same notation
525
as for dictionaries, but note that to iterate through the keys in a **Map** you
526
must use the **Map** method **keySet()** rather than the Python dictionary
527
method **keys()**.
529
The **jmap** and **jset** objects are instances of Java's **HashMap**
530
and **HashSet**, again created as if those classes were just native
531
Python components. In the **for** loop, the **put()** and **add()**
532
methods work just like they do in Java. Also, indexing into a Java
533
**Map** uses the same notation as for dictionaries, but note that to
534
iterate through the keys in a **Map** you must use the **Map** method
535
**keySet()** rather than the Python dictionary method **keys()**.
528
536
529
The final part of the example shows the use of a Java class that I created from
530
scratch, to demonstrate how trivial it is. Notice also that Jython intuitively
531
understands JavaBeans properties, since you can either use the **getVal()** and
532
**setVal()** methods, or assign to and read from the equivalent **val**
533
property. Also, **getChars()** returns a **Character[]** in Java, and this
534
automatically becomes an array in Python.
537
The final part of the example shows the use of a Java class that I
538
created from scratch, to demonstrate how trivial it is. Notice also
539
that Jython intuitively understands JavaBeans properties, since you
540
can either use the **getVal()** and **setVal()** methods, or assign to
541
and read from the equivalent **val** property. Also, **getChars()**
542
returns a **Character[]** in Java, and this automatically becomes an
543
array in Python.
535
544
536
The easiest way to use Java classes that you create for use inside a Python
537
program is to put them inside a package. Although Jython can also import
538
unpackaged java classes (**import JavaClass**), all such unpackaged java classes
539
will be treated as if they were defined in different packages so they can only
540
see each other's public methods.
545
The easiest way to use Java classes that you create for use inside a
546
Python program is to put them inside a package. Although Jython can
547
also import unpackaged java classes (**import JavaClass**), all such
548
unpackaged java classes will be treated as if they were defined in
549
different packages so they can only see each other's public methods.
541
550
542
Java packages translate into Jython modules, and Jython must import a module in
543
order to be able to use the Java class. Here is the Java code for **JavaClass**:
551
Java packages translate into Jython modules, and Jython must import a
552
module in order to be able to use the Java class. Here is the Java
553
code for **JavaClass**:
544
554
545
555
..  code-block:: java
546
556
@@ -582,41 +592,43 @@ order to be able to use the Java class.
582
592
      }
583
593
    }
584
594
585
You can see that this is just an ordinary Java class, without any awareness that
586
it will be used in a Jython program. For this reason, one of the important uses
587
of Jython is in testing Java code [#]_. Because Python is such a powerful,
588
flexible, dynamic language it is an ideal tool for automated test frameworks,
589
without making any changes to the Java code that's being tested.
595
You can see that this is just an ordinary Java class, without any
596
awareness that it will be used in a Jython program. For this reason,
597
one of the important uses of Jython is in testing Java code
598
[#]_. Because Python is such a powerful, flexible, dynamic language it
599
is an ideal tool for automated test frameworks, without making any
600
changes to the Java code that's being tested.
590
601
591
602
Inner Classes
592
603
------------------------------------------------------------------------------
593
604
594
Inner classes becomes attributes on the class object. Instances of **static**
595
inner classes can be created with the usual call::
605
Inner classes becomes attributes on the class object. Instances of
606
**static** inner classes can be created with the usual call::
596
607
597
608
    com.foo.JavaClass.StaticInnerClass()
598
609
599
Non-**static** inner classes must have an outer class instance supplied
600
explicitly as the first argument::
610
Non-**static** inner classes must have an outer class instance
611
supplied explicitly as the first argument::
601
612
602
613
    com.foo.JavaClass.InnerClass(com.foo.JavaClass())
603
614
604
615
Controlling the Interpreter
605
616
=======================================================================
606
617
607
In the rest of this chapter, we shall look at more sophisticated ways to
608
interact with Jython. The simplest way to exercise more control over the
609
**PythonInterpreter** object from within Java is to send data to the
610
interpreter, and pull data back out.
618
In the rest of this chapter, we shall look at more sophisticated ways
619
to interact with Jython. The simplest way to exercise more control
620
over the **PythonInterpreter** object from within Java is to send data
621
to the interpreter, and pull data back out.
611
622
612
623
Putting Data In
613
624
--------------------------------------------------------------------------------
614
625
615
To inject data into your Python program, the **PythonInterpreter** class has a
616
deceptively simple method: **set()**. However, **set()** takes many different
617
data types and performs conversions upon them.  The following example is a
618
reasonably thorough exercise of the various **set()** possibilities, along with
619
comments that should give a fairly complete explanation:
626
To inject data into your Python program, the **PythonInterpreter**
627
class has a deceptively simple method: **set()**. However, **set()**
628
takes many different data types and performs conversions upon them.
629
The following example is a reasonably thorough exercise of the various
630
**set()** possibilities, along with comments that should give a fairly
631
complete explanation:
620
632
621
633
..  code-block:: java
622
634
@@ -713,51 +725,55 @@ comments that should give a fairly compl
713
725
      }
714
726
    }
715
727
716
As usual with Java, the distinction between real objects and primitive types
717
causes trouble. In general, if you pass a regular object to **set()**, it knows
718
what to do with it, but if you want to pass in a primitive you must perform a
719
conversion. One way to do this is to create a "Py" type, such as **PyInteger**
720
or **PyFloat**. but it turns out you can also use Java's own object wrappers
721
like **Integer** and **Float**, which is probably going to be a lot easier to
722
remember.
728
As usual with Java, the distinction between real objects and primitive
729
types causes trouble. In general, if you pass a regular object to
730
**set()**, it knows what to do with it, but if you want to pass in a
731
primitive you must perform a conversion. One way to do this is to
732
create a "Py" type, such as **PyInteger** or **PyFloat**. but it turns
733
out you can also use Java's own object wrappers like **Integer** and
734
**Float**, which is probably going to be a lot easier to remember.
723
735
724
Early in the program you'll see an **exec()** containing the Python statement::
736
Early in the program you'll see an **exec()** containing the Python
737
statement::
725
738
726
739
    print(a[5:])
727
740
728
The colon inside the indexing statement indicates a Python *slice*, which
729
produces a range of elements from the original array. In this case, it produces
730
an array containing the elements from number 5 until the end of the array. You
731
could also say '**a[3:5]**' to produce elements 3 through 5, or '**a[:5]**' to
732
produce the elements zero through 5. The reason a slice is used in this
733
statement is to make sure that the Java **String** has really been converted to
734
a Python string, which can also be treated as an array of characters.
741
The colon inside the indexing statement indicates a Python *slice*,
742
which produces a range of elements from the original array. In this
743
case, it produces an array containing the elements from number 5 until
744
the end of the array. You could also say '**a[3:5]**' to produce
745
elements 3 through 5, or '**a[:5]**' to produce the elements zero
746
through 5. The reason a slice is used in this statement is to make
747
sure that the Java **String** has really been converted to a Python
748
string, which can also be treated as an array of characters.
735
749
736
You can see that it's possible, using **exec()**, to create a Python function
737
(although it's a bit awkward). The **prt()** function prints the whole array,
738
and then (to make sure it's a real Python array), iterates through each element
739
of the array and prints it. Finally, it prints the class of the array, so we can
740
see what conversion has taken place (Python not only has run-time type
741
information, it also has the equivalent of Java reflection). The **prt()**
742
function is used to print arrays that come from each of the Java primitive
743
types.
750
You can see that it's possible, using **exec()**, to create a Python
751
function (although it's a bit awkward). The **prt()** function prints
752
the whole array, and then (to make sure it's a real Python array),
753
iterates through each element of the array and prints it. Finally, it
754
prints the class of the array, so we can see what conversion has taken
755
place (Python not only has run-time type information, it also has the
756
equivalent of Java reflection). The **prt()** function is used to
757
print arrays that come from each of the Java primitive types.
744
758
745
Although a Java **ArrayList** does pass into the interpreter using **set()**,
746
and you can index into it as if it were an array, trying to create a slice
747
fails. To completely convert it into an array, one approach is to simply extract
748
a Java array using **toArray()**, and pass that in. The **set()** method
749
converts it to a **PyArray** -- one of the classes provided with Jython -- which
750
can be treated as a Python array (you can also explicitly create a **PyArray**,
751
but this seems unnecessary).
759
Although a Java **ArrayList** does pass into the interpreter using
760
**set()**, and you can index into it as if it were an array, trying to
761
create a slice fails. To completely convert it into an array, one
762
approach is to simply extract a Java array using **toArray()**, and
763
pass that in. The **set()** method converts it to a **PyArray** -- one
764
of the classes provided with Jython -- which can be treated as a
765
Python array (you can also explicitly create a **PyArray**, but this
766
seems unnecessary).
752
767
753
Finally, a **Map** is created and passed directly into the interpreter. While it
754
is possible to do simple things like index into the resulting object, it's not a
755
real Python dictionary so you can't (for example) call the **keys()** method.
756
There is no straightforward way to convert a Java **Map** into a Python
757
dictionary, and so I wrote a utility called **toPyDictionary()** and made it a
758
**static** method of **net.mindview.python.PyUtil**. This also includes
759
utilities to extract a Python array into a Java **List**, and a Python
760
dictionary into a Java **Map**:
768
Finally, a **Map** is created and passed directly into the
769
interpreter. While it is possible to do simple things like index into
770
the resulting object, it's not a real Python dictionary so you can't
771
(for example) call the **keys()** method.  There is no straightforward
772
way to convert a Java **Map** into a Python dictionary, and so I wrote
773
a utility called **toPyDictionary()** and made it a **static** method
774
of **net.mindview.python.PyUtil**. This also includes utilities to
775
extract a Python array into a Java **List**, and a Python dictionary
776
into a Java **Map**:
761
777
762
778
..  code-block:: java
763
779
@@ -815,7 +831,6 @@ dictionary into a Java **Map**:
815
831
      }
816
832
    }
817
833
818
819
834
Here is the unit testing code:
820
835
821
836
..  code-block:: java
@@ -872,24 +887,27 @@ Getting Data Out
872
887
--------------------------------------------------------------------------------
873
888
874
889
There are a number of different ways to extract data from the
875
**PythonInterpreter**. If you simply call the **get()** method, passing it the
876
object identifier as a string, it returns a **PyObject** (part of the
877
**org.python.core** support classes). It's possible to "cast" it using the
878
**__tojava__()** method, but there are better alternatives:
890
**PythonInterpreter**. If you simply call the **get()** method,
891
passing it the object identifier as a string, it returns a
892
**PyObject** (part of the **org.python.core** support classes). It's
893
possible to "cast" it using the **__tojava__()** method, but there are
894
better alternatives:
879
895
880
896
881
1.  The convenience methods in the **Py** class, such as **py2int()**, take a
882
    **PyObject** and convert it to a number of different types.
897
1.  The convenience methods in the **Py** class, such as **py2int()**,
898
    take a **PyObject** and convert it to a number of different types.
883
899
884
2.  An overloaded version of **get()** takes the desired Java **Class** object
885
    as a second argument, and produces an object that has that run-time type (so you
886
    still need to perform a cast on the result in your Java code).
900
2.  An overloaded version of **get()** takes the desired Java
901
    **Class** object as a second argument, and produces an object that
902
    has that run-time type (so you still need to perform a cast on the
903
    result in your Java code).
887
904
888
Using the second approach, getting an array from the **PythonInterpreter** is
889
quite easy. This is especially useful because Python is exceptionally good at
890
manipulating strings and files, and so you will commonly want to extract the
891
results as an array of strings. For example, you can do a wildcard expansion of
892
file names using Python's **glob()**, as shown further down in the following
905
Using the second approach, getting an array from the
906
**PythonInterpreter** is quite easy. This is especially useful because
907
Python is exceptionally good at manipulating strings and files, and so
908
you will commonly want to extract the results as an array of
909
strings. For example, you can do a wildcard expansion of file names
910
using Python's **glob()**, as shown further down in the following
893
911
code:
894
912
895
913
..  code-block:: java
@@ -996,19 +1014,21 @@ code:
996
1014
      }
997
1015
    }
998
1016
999
The last two examples show the extraction of Python tuples and lists into Java
1000
**List**\s, and Python dictionaries into Java **Map**\s. Both of these cases
1001
require more processing than is provided in the standard Jython library, so I
1002
have again created utilities in **net.mindview.pyton.PyUtil**: **toList()** to
1003
produce a **List** from a Python sequence, and **toMap()** to produce a **Map**
1004
from a Python dictionary. The **PyUtil** methods make it easier to take
1005
important data structures back and forth between Java and Python.
1017
The last two examples show the extraction of Python tuples and lists
1018
into Java **List**\s, and Python dictionaries into Java
1019
**Map**\s. Both of these cases require more processing than is
1020
provided in the standard Jython library, so I have again created
1021
utilities in **net.mindview.pyton.PyUtil**: **toList()** to produce a
1022
**List** from a Python sequence, and **toMap()** to produce a **Map**
1023
from a Python dictionary. The **PyUtil** methods make it easier to
1024
take important data structures back and forth between Java and Python.
1006
1025
1007
1026
Multiple Interpreters
1008
1027
--------------------------------------------------------------------------------
1009
1028
1010
It's also worth noting that you can have multiple **PythonInterpreter** objects
1011
in a program, and each one has its own name space:
1029
It's also worth noting that you can have multiple
1030
**PythonInterpreter** objects in a program, and each one has its own
1031
name space:
1012
1032
1013
1033
..  code-block:: java
1014
1034
@@ -1036,8 +1056,8 @@ in a program, and each one has its own n
1036
1056
    }
1037
1057
1038
1058
1039
When you run the program you'll see that the value of **a** is distinct within
1040
each **PythonInterpreter**.
1059
When you run the program you'll see that the value of **a** is
1060
distinct within each **PythonInterpreter**.
1041
1061
1042
1062
Creating Java classes with Jython
1043
1063
=======================================================================
@@ -1053,8 +1073,8 @@ code. This can produce very useful resul
1053
1073
treat the results as if they are native Java classes, albeit with
1054
1074
Python power under the hood.
1055
1075
1056
To produce Java classes from Python code, Jython comes with a compiler called
1057
**jythonc**.
1076
To produce Java classes from Python code, Jython comes with a compiler
1077
called **jythonc**.
1058
1078
1059
1079
The process of creating Python classes that will produce Java classes
1060
1080
is a bit more complex than when calling Java classes from Python,
@@ -1069,30 +1089,33 @@ standard location for the Python documen
1069
1089
    def returnArray(self):
1070
1090
        "@sig public java.lang.String[] returnArray()"
1071
1091
1072
The Python definition doesn't specify any return type, but the @sig string gives
1073
the full type information about what is being passed and returned. The
1074
**jythonc** compiler uses this information to generate the correct Java code.
1092
The Python definition doesn't specify any return type, but the @sig
1093
string gives the full type information about what is being passed and
1094
returned. The **jythonc** compiler uses this information to generate
1095
the correct Java code.
1075
1096
1076
There's one other set of rules you must follow in order to get a successful
1077
compilation: you must inherit from a Java class or interface in your Python
1078
class (you do not need to specify the **@sig** signature for methods defined in
1079
the superclass/interface). If you do not do this, you won't get your desired
1080
methods -- unfortunately, **jythonc** gives you no warnings or errors in this
1081
case, but you won't get what you want. If you don't see what's missing, it can
1082
be very frustrating.
1097
There's one other set of rules you must follow in order to get a
1098
successful compilation: you must inherit from a Java class or
1099
interface in your Python class (you do not need to specify the
1100
**@sig** signature for methods defined in the
1101
superclass/interface). If you do not do this, you won't get your
1102
desired methods -- unfortunately, **jythonc** gives you no warnings or
1103
errors in this case, but you won't get what you want. If you don't see
1104
what's missing, it can be very frustrating.
1083
1105
1084
In addition, you must import the appropriate java class and give the correct
1085
package specification.  In the example below, **java** is imported so you must
1086
inherit from **java.lang.Object**, but you could also say **from java.lang
1087
import Object** and then you'd just inherit from **Object** without the package
1088
specification. Unfortunately, you don't get any warnings or errors if you get
1089
this wrong, so you must be patient and keep trying.
1106
In addition, you must import the appropriate java class and give the
1107
correct package specification.  In the example below, **java** is
1108
imported so you must inherit from **java.lang.Object**, but you could
1109
also say **from java.lang import Object** and then you'd just inherit
1110
from **Object** without the package specification. Unfortunately, you
1111
don't get any warnings or errors if you get this wrong, so you must be
1112
patient and keep trying.
1090
1113
1091
Here is an example of a Python class created to produce a Java class. This also
1092
introduces the '**=T**' directive for the makefile builder tool, which specifies
1093
a different target than the one that is normally used by the tool. In this case,
1094
the Python file is used to build a Java **.class** file, so the class file is
1095
the desired target::
1114
Here is an example of a Python class created to produce a Java
1115
class. In this case, the Python file is used to build a Java
1116
**.class** file, so the class file is the desired target:
1117
1118
..  code-block:: python
1096
1119
1097
1120
    # Jython/PythonToJavaClass.py
1098
1121
    # A Python class converted into a Java class
@@ -1170,34 +1193,37 @@ the desired target::
1170
1193
            for x in m.keys():
1171
1194
                print(x, m[x])
1172
1195
1196
First note that **PythonToJavaClass** is inherited from
1197
**java.lang.Object**; if you don't do this you will quietly get a Java
1198
class without the right signatures. You are not required to inherit
1199
from **Object**; any other Java class will do.
1173
1200
1174
First note that **PythonToJavaClass** is inherited from **java.lang.Object**; if
1175
you don't do this you will quietly get a Java class without the right
1176
signatures. You are not required to inherit from **Object**; any other Java
1177
class will do.
1201
This class is designed to demonstrate different arguments and return
1202
values, to provide you with enough examples that you'll be able to
1203
easily create your own signature strings. The first three of these are
1204
fairly self-explanatory, but note the full qualification of the Java
1205
name in the signature string.
1178
1206
1179
This class is designed to demonstrate different  arguments and return values, to
1180
provide you with enough examples that you'll be able to easily create your own
1181
signature strings. The first three of these are fairly self-explanatory, but
1182
note the full qualification of the Java name in the signature string.
1207
In **returnArray()**, a Python array must be returned as a Java
1208
array. To do this, the Jython **array()** function (from the
1209
**jarray** module) must be used, along with the type of the class for
1210
the resulting array. Any time you need to return an array to Java, you
1211
must use **array()**, as seen in the methods **ints()** and
1212
**doubles()**.
1183
1213
1184
In **returnArray()**, a Python array must be returned as a Java array. To do
1185
this, the Jython **array()** function (from the **jarray** module) must be
1186
used, along with the type of the class for the resulting array. Any time you
1187
need to return an array to Java, you must use **array()**, as seen in the
1188
methods **ints()** and **doubles()**.
1214
The last methods show how to pass arguments in from Java. Basic types
1215
happen automatically as long as you specify them in the **@sig**
1216
string, but you must use objects and you cannot pass in primitives
1217
(that is, primitives must be ensconced in wrapper objects, such as
1218
**Integer**).
1189
1219
1190
The last methods show how to pass arguments in from Java. Basic types happen
1191
automatically as long as you specify them in the **@sig** string, but you must
1192
use objects and you cannot pass in primitives (that is, primitives must be
1193
ensconced in wrapper objects, such as **Integer**).
1194
1195
In **argIn3()**, you can see that a Java **List** is transparently converted to
1196
something that behaves just like a Python array, but is not a true array because
1197
you cannot take a slice from it. If you want a true Python array, then you must
1198
create and pass a **PyArray** as in **argIn4()**, where the slice is
1199
successful. Similarly, a Java **Map** must come in as a **PyDictionary** in
1200
order to be treated as a Python dictionary.
1220
In **argIn3()**, you can see that a Java **List** is transparently
1221
converted to something that behaves just like a Python array, but is
1222
not a true array because you cannot take a slice from it. If you want
1223
a true Python array, then you must create and pass a **PyArray** as in
1224
**argIn4()**, where the slice is successful. Similarly, a Java **Map**
1225
must come in as a **PyDictionary** in order to be treated as a Python
1226
dictionary.
1201
1227
1202
1228
Here is the Java program to exercise the Java classes produced by the
1203
1229
above Python code. You can't compile **TestPythonToJavaClass.java**
@@ -1253,31 +1279,33 @@ until **PythonToJavaClass.class** is ava
1253
1279
1254
1280
For Python support, you'll usually only need to import the classes in
1255
1281
**org.python.core**. Everything else in the above example is fairly
1256
straightforward, as **PythonToJavaClass** appears, from the Java side, to be
1257
just another Java class. **dumpClassInfo()** uses reflection to verify that the
1258
method signatures specified in **PythonToJavaClass.py** have come through
1259
properly.
1282
straightforward, as **PythonToJavaClass** appears, from the Java side,
1283
to be just another Java class. **dumpClassInfo()** uses reflection to
1284
verify that the method signatures specified in
1285
**PythonToJavaClass.py** have come through properly.
1260
1286
1261
1287
Building Java Classes from Python
1262
1288
--------------------------------------------------------------------------------
1263
1289
1264
Part of the trick of creating Java classes from Python code is the @sig
1265
information in the method documentation strings. But there's a second problem
1266
which stems from the fact that Python has no "package" keyword -- the Python
1267
equivalent of packages (modules) are implicitly created based on the file name.
1268
However, to bring the resulting class files into the Java program, **jythonc**
1269
must be given information about how to create the Java package for the Python
1270
code. This is done on the **jythonc** command line using the **--package** flag,
1271
followed by the package name you wish to produce (including the separation dots,
1272
just as you would give the package name using the **package** keyword in a Java
1273
program). This will put the resulting **.class** files in the appropriate
1274
subdirectory off of the current directory. Then you only need to import the
1275
package in your Java program, as shown above (you'll need '**.**' in your
1276
CLASSPATH in order to run it from the code directory).
1290
Part of the trick of creating Java classes from Python code is the
1291
@sig information in the method documentation strings. But there's a
1292
second problem which stems from the fact that Python has no "package"
1293
keyword -- the Python equivalent of packages (modules) are implicitly
1294
created based on the file name.  However, to bring the resulting class
1295
files into the Java program, **jythonc** must be given information
1296
about how to create the Java package for the Python code. This is done
1297
on the **jythonc** command line using the **--package** flag, followed
1298
by the package name you wish to produce (including the separation
1299
dots, just as you would give the package name using the **package**
1300
keyword in a Java program). This will put the resulting **.class**
1301
files in the appropriate subdirectory off of the current
1302
directory. Then you only need to import the package in your Java
1303
program, as shown above (you'll need '**.**' in your CLASSPATH in
1304
order to run it from the code directory).
1277
1305
1278
Here are the **make** dependency rules that I used to build the above example
1279
(the backslashes at the ends of the lines are understood by **make** to be line
1280
continuations)::
1306
Here are the **make** dependency rules that I used to build the above
1307
example (the backslashes at the ends of the lines are understood by
1308
**make** to be line continuations)::
1281
1309
1282
1310
    TestPythonToJavaClass.class: \\
1283
1311
            TestPythonToJavaClass.java \\
@@ -1290,25 +1318,27 @@ continuations)::
1290
1318
        PythonToJavaClass.py
1291
1319
1292
1320
The first target, **TestPythonToJavaClass.class**, depends on both
1293
**TestPythonToJavaClass.java** and the **PythonToJavaClass.class**, which is the
1294
Python code that's converted to a class file. This latter, in turn, depends on
1295
the Python source code. Note that it's important that the directory where the
1296
target lives be specified, so that the makefile will create the Java program
1297
with the minimum necessary amount of rebuilding.
1321
**TestPythonToJavaClass.java** and the **PythonToJavaClass.class**,
1322
which is the Python code that's converted to a class file. This
1323
latter, in turn, depends on the Python source code. Note that it's
1324
important that the directory where the target lives be specified, so
1325
that the makefile will create the Java program with the minimum
1326
necessary amount of rebuilding.
1298
1327
1299
1328
Summary
1300
1329
=======================================================================
1301
1330
1302
This chapter has arguably gone much deeper into Jython than required to use the
1303
interpreter design pattern. Indeed, once you decide that you need to use
1304
interpreter and that you're not going to get lost inventing your own language,
1305
the solution of installing Jython is quite simple, and you can at least get
1306
started by following the **GreenHouseController** example.
1331
This chapter has arguably gone much deeper into Jython than required
1332
to use the interpreter design pattern. Indeed, once you decide that
1333
you need to use interpreter and that you're not going to get lost
1334
inventing your own language, the solution of installing Jython is
1335
quite simple, and you can at least get started by following the
1336
**GreenHouseController** example.
1307
1337
1308
Of course, that example is often too simple and you may need something more
1309
sophisticated, often requiring more interesting data to be passed back and
1310
forth. When I encountered the limited documentation, I felt it necessary to come
1311
up with a more thorough examination of Jython.
1338
Of course, that example is often too simple and you may need something
1339
more sophisticated, often requiring more interesting data to be passed
1340
back and forth. When I encountered the limited documentation, I felt
1341
it necessary to come up with a more thorough examination of Jython.
1312
1342
1313
1343
In the process, note that there could be another equally powerful
1314
1344
design pattern lurking in here, which could perhaps be called
@@ -1319,57 +1349,63 @@ much faster than with either language by
1319
1349
to bridge across languages, and at the same time bridging between
1320
1350
computers and operating systems.
1321
1351
1322
To me, Python and Java present a very potent combination for program development
1323
because of Java's architecture and tool set, and Python's extremely rapid
1324
development (generally considered to be 5-10 times faster than C++ or Java).
1325
Python is usually slower, however, but even if you end up re-coding parts of
1326
your program for speed, the initial fast development will allow you to more
1327
quickly flesh out the system and uncover and solve the critical sections. And
1328
often, the execution speed of Python is not a problem -- in those cases it's an
1329
even bigger win. A number of commercial products already use Java and Jython,
1330
and because of the terrific productivity leverage I expect to see this happen
1331
more in the future.
1352
To me, Python and Java present a very potent combination for program
1353
development because of Java's architecture and tool set, and Python's
1354
extremely rapid development (generally considered to be 5-10 times
1355
faster than C++ or Java).  Python is usually slower, however, but even
1356
if you end up re-coding parts of your program for speed, the initial
1357
fast development will allow you to more quickly flesh out the system
1358
and uncover and solve the critical sections. And often, the execution
1359
speed of Python is not a problem -- in those cases it's an even bigger
1360
win. A number of commercial products already use Java and Jython, and
1361
because of the terrific productivity leverage I expect to see this
1362
happen more in the future.
1332
1363
1333
1364
Exercises
1334
1365
=======================================================================
1335
1366
1336
#.  Modify **GreenHouseLanguage.py** so that it checks the times for the events
1337
    and runs those events at the appropriate times.
1367
#.  Modify **GreenHouseLanguage.py** so that it checks the times for
1368
    the events and runs those events at the appropriate times.
1338
1369
1339
#.  Modify **GreenHouseLanguage.py** so that it calls a function for **action**
1340
    instead of just printing a string.
1370
#.  Modify **GreenHouseLanguage.py** so that it calls a function for
1371
    **action** instead of just printing a string.
1341
1372
1342
#.  Create a Swing application with a **JTextField** (where the user will enter
1343
    commands) and a **JTextArea** (where the command results will be displayed).
1344
    Connect to a **PythonInterpreter** object so that the output will be sent to
1345
    the **JTextArea** (which should scroll). You'll need to locate the
1346
    **PythonInterpreter** command that redirects the output to a Java stream.
1373
#.  Create a Swing application with a **JTextField** (where the user
1374
    will enter commands) and a **JTextArea** (where the command
1375
    results will be displayed).  Connect to a **PythonInterpreter**
1376
    object so that the output will be sent to the **JTextArea** (which
1377
    should scroll). You'll need to locate the **PythonInterpreter**
1378
    command that redirects the output to a Java stream.
1347
1379
1348
#.  Modify **GreenHouseLanguage.py** to add a master controller class (instead
1349
    of the static array inside **Event**) and provide a **run()** method for
1350
    each of the subclasses. Each **run()** should create and use an object from
1351
    the standard Java library during its execution. Modify
1352
    **GreenHouseController.java** to use this new class.
1380
#.  Modify **GreenHouseLanguage.py** to add a master controller class
1381
    (instead of the static array inside **Event**) and provide a
1382
    **run()** method for each of the subclasses. Each **run()** should
1383
    create and use an object from the standard Java library during its
1384
    execution. Modify **GreenHouseController.java** to use this new
1385
    class.
1353
1386
1354
#.  Modify the resulting **GreenHouseLanguage.py** from exercise two to produce
1355
    Java classes (add the @sig documentation strings to produce the correct Java
1356
    signatures, and create a makefile to build the Java **.class** files). Write
1357
    a Java program that uses these classes.
1387
#.  Modify the resulting **GreenHouseLanguage.py** from exercise two
1388
    to produce Java classes (add the @sig documentation strings to
1389
    produce the correct Java signatures, and create a makefile to
1390
    build the Java **.class** files). Write a Java program that uses
1391
    these classes.
1358
1392
1359
#.  Modify **GreenHouseLanguage.py** so that the subclasses of **Event** are not
1360
    discrete classes, but are instead *generated* by a single function which creates
1361
    the class and the associated string dynamically.
1393
#.  Modify **GreenHouseLanguage.py** so that the subclasses of
1394
    **Event** are not discrete classes, but are instead *generated* by
1395
    a single function which creates the class and the associated
1396
    string dynamically.
1362
1397
1363
1398
.. rubric:: Footnotes
1364
1399
1365
.. [#]  The original version of this was called *JPython*\, but the project
1366
        changed and the name was changed to emphasize the distinctness of the new
1367
        version.
1400
.. [#] 	The original version of this was called *JPython*\, but the
1401
        project changed and the name was changed to emphasize the
1402
        distinctness of the new version.
1368
1403
1369
.. [#]  Changing the registry setting **python.security.respectJavaAccessibility
1370
        = true** to **false** makes testing even more powerful because it allows
1371
        the test script to use *all* methods, even protected and package-
1372
        private.
1404
.. [#]  Changing the registry setting
1405
        **python.security.respectJavaAccessibility = true** to
1406
        **false** makes testing even more powerful because it allows
1407
        the test script to use *all* methods, even protected and
1408
        package- private.
1373
1409
1374
1410
1375
1411