<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Code Penguin</title>
	
	<link>http://www.codepenguin.com</link>
	<description>Constantly tinkering with things...</description>
	<lastBuildDate>Sat, 03 Sep 2011 22:53:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/codepenguin/SpFe" /><feedburner:info uri="codepenguin/spfe" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>codepenguin/SpFe</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Slipix Version 1.0 for iOS</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/gBhnmbda-Hs/</link>
		<comments>http://www.codepenguin.com/2011/09/01/slipix-version-1-0-for-ios/#comments</comments>
		<pubDate>Fri, 02 Sep 2011 02:21:43 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.codepenguin.com/?p=734</guid>
		<description><![CDATA[Introduction Slipix is a unique new puzzle game where you touch and drag different layers of an image until the real picture is revealed. These are not jigsaw puzzles. Each layer is a different design or pattern that create unique challenges. There are 40 unique levels to master with four difficulty levels. Quick Play mode [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p><a href="http://itunes.apple.com/us/app/when/id460793726?mt=8"><img src="/wp-content/uploads/2011/09/Icon@2x.png" alt="Slipix Logo" title="Slipix Logo" width="114" height="114" class="alignright size-full" /></a></p>
<p>
Slipix is a unique new puzzle game where you touch and drag different layers of an image until the real picture is revealed. These are not jigsaw puzzles. Each layer is a different design or pattern that create unique challenges.
</p>
<p>
There are 40 unique levels to master with four difficulty levels. Quick Play mode can generate an endless amount of levels to satisfy any puzzle solver. There is even a head to head multiplayer mode (iPad only) so you can play with your friends.
</p>
<p>
More levels are on the way!
</p>
<p><center><a href="http://itunes.apple.com/us/app/when/id460793726?mt=8">Click here to check it out in the App Store!</a><br/></center><br />
<br/>
</p>
<h2>Video</h2>
<p><object width="500" height="306"><param name="movie" value="http://www.youtube.com/v/UflM0cVg3wY?version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/UflM0cVg3wY?version=3" type="application/x-shockwave-flash" width="500" height="306" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h2>Screen Shots</h2>
<p>
<a href="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-1.png"><img src="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-1.png" alt="" title="Slipix Screenshot 1" width="480" height="320" class="alignnone size-full wp-image-723" /></a>
</p>
<p>
<a href="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-2.png"><img src="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-2.png" alt="" title="Slipix Screenshot 2" width="480" height="320" class="alignnone size-full wp-image-724" /></a>
</p>
<p>
<a href="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-3.png"><img src="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-3.png" alt="" title="Slipix Screenshot 3" width="480" height="320" class="alignnone size-full wp-image-725" /></a>
</p>
<p>
<a href="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-4.png"><img src="http://www.codepenguin.com/wp-content/uploads/2011/09/photo-4.png" alt="" title="Slipix Screenshot 4" width="480" height="320" class="alignnone size-full wp-image-726" /></a>
</p>
<h2>Support</h2>
<p>
Have a comment, need help or have suggestions for new categories and events?  I&#8217;d love to hear from you.  Use the <a href="/slipixapp/support">support/contact form</a> or leave a comment in the comments section and I&#8217;ll get back to you as soon as I can.  Thanks!</p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/gBhnmbda-Hs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2011/09/01/slipix-version-1-0-for-ios/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2011/09/01/slipix-version-1-0-for-ios/</feedburner:origLink></item>
		<item>
		<title>Portable Google App Engine For Windows (Enhanced)</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/WVV-YoUHn8w/</link>
		<comments>http://www.codepenguin.com/2011/01/09/portable-google-app-engine-for-windows-enhanced/#comments</comments>
		<pubDate>Sun, 09 Jan 2011 18:46:32 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.codepenguin.com/?p=642</guid>
		<description><![CDATA[5/12/2011: Updated to support Google App Engine Version 1.5.0. A while back I put together the information and steps to get Google App Engine running on Windows wrapped up in a portable little bundle. Since it has been a while I thought it could use a good refresh with the latest versions of everything and [...]]]></description>
			<content:encoded><![CDATA[<p><b>5/12/2011: Updated to support Google App Engine Version 1.5.0.</b></p>
<p>A while back I put together the information and steps to get Google App Engine running on Windows wrapped up in a portable little bundle.  Since it has been a while I thought it could use a good refresh with the latest versions of everything and make things work more like the real Google App Engine. Some of the content may seem the same as last time but there definitely will be some new ways of running things and new capabilities that were not available last time.  This new way is much easier and should keep up with all the changes that newer versions of Google App Engine may bring.</p>
<p><span id="more-642"></span></p>
<h2>Installation</h2>
<p>Let&#8217;s gather all the files that we are going to need.  I throw the version numbers on here that this was written for but yours may vary slightly.  Download the following:</p>
<ul>
<li><a title="Portable Python" href="http://www.portablepython.com/wiki/Download">Portable Python</a> (Download the 2.5.x release.  I am using 2.5.4 at the moment.)</li>
<li><a title="Google App Engine SDK" href="http://code.google.com/appengine/downloads.html">Google App Engine SDK</a> (Download the Linux/Other Platforms release.  I am using 1.4.1-2011-01-05 at the moment.)</li>
</ul>
<p>Now that you&#8217;ve got all the files, you can grab a USB thumb drive or even just install it to a directory on your local machine.  Run the Portable Python installer and specify the location you&#8217;d like to store it.  I will refer to this location as the &#8220;Portable Python folder&#8221; from here on.</p>
<p>Extract the &#8220;google_appengine&#8221; folder from the Google App Engine SDK zip file into the Portable Python folder on your thumb drive.  Side Note: In the future if you ever want to update to a newer release, just delete the &#8220;google_appengine&#8221; folder and extract a new copy from the latest zip file from Google.</p>
<p>Create a new folder in your Portable Python folder called &#8220;google_appengine_datastores&#8221;.  This is where we are going to store all the data for our apps.</p>
<p>Create two new files called &#8220;dev_appserver.py.bat&#8221; and &#8220;appcfg.py.bat&#8221; in your Portable Python folder both with the following contents:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">@echo off
REM Portable Google App Engine Command Line Rewriter
REM Written by David Lambert (http://www.codepenguin.com)
&nbsp;
REM Execute the command line rewriting script
app\python.exe _cmdrewrite.py %0 %*
REM Execute the new command line batch file
_cmdrewrite.bat</pre></td></tr></table></div>

<p>Create a new file called &#8220;_cmdrewrite.py&#8221; in your Portable Python folder with the following contents:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#Portable Google App Engine Command Line Rewriter</span>
<span style="color: #808080; font-style: italic;">#Written by David Lambert (http://www.codepenguin.com)</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#Rewrite the command line with correct paths</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>, <span style="color: #dc143c;">os</span>, <span style="color: #dc143c;">re</span>
new_cmd = <span style="color: #483d8b;">'app<span style="color: #000099; font-weight: bold;">\p</span>ython.exe google_appengine/%s'</span> <span style="color: #66cc66;">%</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
gae_version = <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'release: &quot;(.*?)&quot;'</span>,<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'google_appengine/VERSION'</span>,<span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
appname = <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/'</span><span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'/'</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">'dev_appserver.py'</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">path</span>.<span style="color: black;">exists</span><span style="color: black;">&#40;</span>appname<span style="color: black;">&#41;</span>:
  new_cmd += <span style="color: #483d8b;">' --blobstore_path=google_appengine_datastores/%s_blobstore'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>appname<span style="color: black;">&#41;</span>
  new_cmd += <span style="color: #483d8b;">' --datastore_path=google_appengine_datastores/%s_datastore'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>appname<span style="color: black;">&#41;</span>
  new_cmd += <span style="color: #483d8b;">' --history_path=google_appengine_datastores/%s_history'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>appname<span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> gae_version <span style="color: #66cc66;">&gt;</span>= <span style="color: #483d8b;">&quot;1.5.0&quot;</span>:
    new_cmd += <span style="color: #483d8b;">' --skip_sdk_update_check'</span>
    new_cmd += <span style="color: #483d8b;">' --rdbms_sqlite_path=google_appengine_datastores/%s_rdbms'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span>appname<span style="color: black;">&#41;</span>
new_cmd += <span style="color: #483d8b;">&quot; &quot;</span> + <span style="color: #483d8b;">&quot; &quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;">#Write new command to the batch file</span>
f = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'_cmdrewrite.bat'</span>,<span style="color: #483d8b;">'w'</span><span style="color: black;">&#41;</span>
f.<span style="color: black;">write</span><span style="color: black;">&#40;</span>new_cmd<span style="color: black;">&#41;</span>
f.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>The above three files make up the command line rewriting system.  It basically will take a normal command line that you see on the Google App Engine tutorials and documentation and rewrite them to work with Portable Python.  This makes the Portable Google App Engine system much more useful because you can easily follow along with the real documentation and tutorials without having to adjust or rewrite your own command lines.  It also makes the datastore and history files portable by storing them in the &#8220;google_appengine_datastore&#8221; folder created earlier.</p>
<h2>Creating your Application</h2>
<p>Now that we&#8217;ve done all the prep work let&#8217;s see how this thing actually works.  Creating a new application does take a few steps but they are pretty basic and boring.  The quick and dirty steps are as follows:</p>
<ol>
<li>Create the App folder.</li>
<li>Create a bunch of source files in your App folder.</li>
<li>Run your App!</li>
</ol>
<p>I&#8217;ll walk you through all the above steps to give you an idea of what is going on.  We are going to use the example source from Google for the actual example app content parts.  It is a great idea to read over their <a href="http://code.google.com/appengine/docs/python/gettingstarted/">documentation</a> as it will give you more insight into how the Google App Engine works.</p>
<p>All of our applications are going to reside in their own folders inside the Portable Python folder.  Create a new  folder called &#8220;helloworld&#8221; in your Portable Python folder.  I&#8217;ll refer to this as the App folder from now on as all the important files will go inside this folder for our first app.  The next few steps come directly from the <a href="http://code.google.com/appengine/docs/python/gettingstarted/helloworld.html">Hello World tutorial</a> from Google.</p>
<p>Create a new file called &#8220;helloworld.py&#8221; in your App folder with the following contents:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Content-Type: text/plain'</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">''</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Hello, world!'</span></pre></td></tr></table></div>

<p>Create a new file called &#8220;app.yaml&#8221; in your App folder with the following contents:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="text" style="font-family:monospace;">application: helloworld
version: 1
runtime: python
api_version: 1
&nbsp;
handlers:
- url: /.*
  script: helloworld.py</pre></td></tr></table></div>

<p>The super important file here is the &#8220;app.yaml&#8221;.  You can think of it as the master control center of your App.  It has all the settings and such that tell Google App Engine what to do.  <a href="http://code.google.com/appengine/docs/python/config/appconfig.html">Google&#8217;s documentation</a> lays out everything for this file.  We&#8217;ve got enough in ours above to get going but I definitely recommend reading their docs when you get a chance.</p>
<h2>Running your Application</h2>
<p>Our HelloWorld App is ready to go!  Let&#8217;s get this thing up and running.  We are going to need a new command interpreter window opened to our Portable Python folder.  Now type the following:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">dev_appserver.py helloworld</pre></div></div>

<p>After pressing enter you should see something close to the following:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">P:\PortablePython_1.1_py2.5.4&gt;dev_appserver.py helloworld
INFO     2011-01-08 15:21:00,736 appengine_rpc.py:153] Server: appengine.google.com
WARNING  2011-01-08 15:21:00,743 datastore_file_stub.py:573] Could not read data
store data from P:\PortablePython_1.1_py2.5.4\google_appengine_datastores\helloworld_datastore
INFO     2011-01-08 15:21:01,075 dev_appserver_main.py:485] Running application
helloworld on port 8080: http://localhost:8080</pre></div></div>

<p>You can ignore the warning in the middle that says &#8220;Could not read data store data&#8221;.  That just means that the datastore has not been created yet.  Now open a web browser and point it to the following URL: http://localhost:8080.  You should now see &#8220;Hello, world!&#8221; in your browser! That is it!  Your first Google App Engine application is running.  When you want to stop your application press Ctrl+Pause/Break.  It will prompt you &#8220;Terminate batch job (Y/N)?&#8221; so just press &#8216;y&#8217; and then press enter.</p>
<h2>Other available commands</h2>
<p>Google App Engine&#8217;s dev_appserver.py has a lot of options and functionality to help you manage your application.  The new command rewriting system should be compatible with all the options that are available.  You should definitely read through the options in their <a href="http://code.google.com/appengine/docs/python/tools/devserver.html">documentation</a> so that you can utilize things like clearing the datastore, changing the webserver port, using SQLite for the datastore and much more.  Let&#8217;s look at a few of these commands that you will see in the tutorials.</p>
<p>To run the development app server and clear the current datastore use the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">dev_appserver.py --clear_datastore helloworld</pre></div></div>

<p>To run the development app server using port 9999 use the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">dev_appserver.py --port=9999 helloworld</pre></div></div>

<p>If you want to use SQLite for the datastore (increased performance for large amounts of content), use the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">dev_appserver.py --use_sqlite helloworld</pre></div></div>

<p>You also can use the <a href="http://code.google.com/appengine/docs/python/tools/uploadinganapp.html">appcfg.py</a> commands to upload your application by using the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">appcfg.py update helloworld</pre></div></div>

<h2>Conclusion</h2>
<p>You now have a fully functioning Portable Google App Engine development environment!  You can follow all the tutorials on the <a href="http://code.google.com/appengine/docs/python/gettingstarted/">Google App Engine website</a> with ease.  If you ever need to update the Google App Engine SDK, just delete the google_appengine folder from your Portable Python folder and extract the new one from the main download site.   If you have any questions or ideas on how to improve this system, please let me know!</p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/WVV-YoUHn8w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2011/01/09/portable-google-app-engine-for-windows-enhanced/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2011/01/09/portable-google-app-engine-for-windows-enhanced/</feedburner:origLink></item>
		<item>
		<title>Growing Pains</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/T3ixv8ijygw/</link>
		<comments>http://www.codepenguin.com/2010/10/04/growing-pains/#comments</comments>
		<pubDate>Tue, 05 Oct 2010 01:47:34 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://beta.codepenguin.com/?p=3</guid>
		<description><![CDATA[I recently moved to a new website host and have been in the process of migrating the main site and tools section over. It seems that in the transition the URL styles were not set correctly causing some of the older links to not work. This has been repaired. Sorry if you got a bunch [...]]]></description>
			<content:encoded><![CDATA[<p>I recently moved to a new website host and have been in the process of migrating the main site and tools section over.  It seems that in the transition the URL styles were not set correctly causing some of the older links to not work.  This has been repaired.  Sorry if you got a bunch of &#8220;Page not found!&#8221; errors over the last week.</p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/T3ixv8ijygw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2010/10/04/growing-pains/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2010/10/04/growing-pains/</feedburner:origLink></item>
		<item>
		<title>When? Version 1.0.3 Just released in the App Store!</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/iLoaeLgXIME/</link>
		<comments>http://www.codepenguin.com/2010/08/26/when-version-1-0-3-just-released-in-the-app-store/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 17:08:15 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.codepenguin.com/?p=629</guid>
		<description><![CDATA[I am happy to announce that version 1.0.3 of When? has just been released in the App Store! Click here to check it out in the App Store! This version includes holidays/events for a bunch of new countries: Austria Belgium Denmark Finland France Hong Kong India Ireland Italy Luxembourg Mexico Netherlands Norway New Zealand Russia [...]]]></description>
			<content:encoded><![CDATA[<p><img src="/wp-content/uploads/2010/07/application_icon_114.png" alt="When? Logo" title="When? Logo" width="114" height="114" class="alignleft size-full wp-image-590" /><br />
I am happy to announce that version 1.0.3 of <a href="/whenapp">When?</a> has just been released in the App Store!<br />
<br/><center><a href="http://itunes.apple.com/us/app/when/id383269665?mt=8">Click here to check it out in the App Store!</a></center><br/></br><span id="more-629"></span><br />
<br/><br/><br/><br />
<div id="attachment_630" class="wp-caption alignright" style="width: 330px"><img src="/wp-content/uploads/2010/08/when1_0_3.jpg" alt="When Version 1.0.3" title="When Version 1.0.3" width="320" height="480" class="size-full wp-image-630" /><p class="wp-caption-text">When Version 1.0.3</p></div></p>
<p>
This version includes holidays/events for a bunch of new countries:</p>
<ul>
<li>Austria</li>
<li>Belgium</li>
<li>Denmark</li>
<li>Finland</li>
<li>France</li>
<li>Hong Kong</li>
<li>India</li>
<li>Ireland</li>
<li>Italy</li>
<li>Luxembourg</li>
<li>Mexico</li>
<li>Netherlands</li>
<li>Norway</li>
<li>New Zealand</li>
<li>Russia</li>
<li>Singapore</li>
<li>Spain</li>
<li>Switzerland</li>
<li>Sweden</li>
</ul>
<p><br/><br />
I&#8217;ve got a few Promo Codes available to anyone who would like to try it.  First come first serve basis.  If you like it (or not) please leave a review on the App Store.  I&#8217;m always open to new ideas and suggestions.</p>
<p>Promo Codes:</p>
<ul>
<li>PEYTEJA33AWW</li>
<li>FAXAXXRRJK3K</li>
<li>FM6HJMENEE9Y</li>
<li>YLWPYM4NMLLY</li>
<li>KPPA6LMNRPWM</li>
<li>NAYAJ4XJXYYR</li>
<li>JKW9JAM4L6ER</li>
<li>MMJ9J69TF9KP</li>
<li>NRRLLY3X49RX</li>
<ul>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/iLoaeLgXIME" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2010/08/26/when-version-1-0-3-just-released-in-the-app-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2010/08/26/when-version-1-0-3-just-released-in-the-app-store/</feedburner:origLink></item>
		<item>
		<title>When? Holidays and Important Events App for iOS4 Devices</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/_Dvi0aW5BD4/</link>
		<comments>http://www.codepenguin.com/2010/07/28/when-holidays-and-important-events-app-for-ios4-devices/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 01:29:58 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[iphone]]></category>

		<guid isPermaLink="false">http://www.codepenguin.com/?p=617</guid>
		<description><![CDATA[Introduction Do you want to know when Mother&#8217;s Day is this year? Wouldn&#8217;t it be easier to have it on your calendar? It gets pretty tedious adding all those important events and holidays by hand. When? is an App for iOS4 Devices that allows you to easily find and add holidays and important events to [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p><img src="/wp-content/uploads/2010/07/application_icon_114.png" alt="When? Logo" title="When? Logo" width="114" height="114" class="alignright size-full wp-image-590" /></p>
<p>
Do you want to know when Mother&#8217;s Day is this year?  Wouldn&#8217;t it be easier to have it on your calendar?  It gets pretty tedious adding all those important events and holidays by hand.  <strong>When?</strong> is an App for iOS4 Devices that allows you to easily find and add holidays and important events to your built in calendar.
</p>
<p>
It contains important events for many countries (with states or provinces where applicable) and religions.  New categories and events will be continually added.  <strong>When?</strong> makes it simple to add events to your calendar in two easy steps:</p>
<ol>
<li>Find the event or events you want using categories.</li>
<li>Tap the + button and the event is immediately added to your calendar!</li>
</ol>
<p>You can even add an entire category with just two taps.  Tired of having an event on your calendar?  Remove it just as easy by pressing the red check mark. That is all you need to do!</p>
<p><center><a href="http://itunes.apple.com/us/app/when/id383269665?mt=8">Click here to check it out in the App Store!</a><br/></center><br />
<br/></p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/_Dvi0aW5BD4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2010/07/28/when-holidays-and-important-events-app-for-ios4-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2010/07/28/when-holidays-and-important-events-app-for-ios4-devices/</feedburner:origLink></item>
		<item>
		<title>WebSolver: An Interactive Cryptogram Solver for the Web!</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/5kTPAioAdJM/</link>
		<comments>http://www.codepenguin.com/2010/06/19/websolver-an-interactive-cryptogram-solver-for-the-web/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 05:48:37 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ACA]]></category>
		<category><![CDATA[aristocrat]]></category>
		<category><![CDATA[cryptograms]]></category>
		<category><![CDATA[patristocrat]]></category>
		<category><![CDATA[solver]]></category>

		<guid isPermaLink="false">http://www.codepenguin.com/?p=505</guid>
		<description><![CDATA[A great carpenter does not need to know how to make a hammer or saw in order to create a masterpiece. A while back I wrote a bunch of articles describing how to create your own interactive cryptogram solver using python. I&#8217;ve used it a lot in my own personal solving and have had a [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>
A great carpenter does not need to know how to make a hammer or saw in order to create a masterpiece.
</p></blockquote>
<p>
<a href="http://tools.codepenguin.com/websolver/"><img src="/wp-content/uploads/2010/06/websolver_start.jpg" alt="Web Solver: Start" title="Web Solver: Start" width="296" height="147" class="alignright size-full wp-image-514" /></a><br />
A while back I wrote a bunch of articles describing how to create your own <a href="/2009/09/17/creating-an-interactive-cryptogram-solver-introduction/">interactive cryptogram solver</a> using python.  I&#8217;ve used it a lot in my own personal solving and have had a few friends use it too but it definitely is not a tool for everyone.  There are a lot of great tools out there for solving ciphers but many of them are very technical, require a special environment to run, or require programming knowledge and experience.  Now, I don&#8217;t want to down play the usefulness of these great tools or tell anyone that they shouldn&#8217;t learn computer programming (Note: I think all computer users should know the very basics of programming logic as it is so useful for many things).  That being said, there are many people out there who love a good challenge but either don&#8217;t have the desire or the time to learn to program.  Sometimes the greater skill is knowing how to use the tools properly and efficiently.  A great carpenter does not need to know how to make a hammer or saw in order to create a masterpiece.
</p>
<p>
So for all you great carpenters (solvers) out there, I have ported my interactive cryptogram solver to the web!  No downloads, no special environments (other than a modern web browser), and no programming skills needed.  Just a clean area where you can do what you do best: solving.
</p>
<p><span id="more-505"></span></p>
<p>
<strong>Web Solver is available now at <a href="http://tools.codepenguin.com/websolver/">http://tools.codepenguin.com/websolver/</a>. </strong>
</p>
<p>
At the moment, the Web Solver only has support for Aristocrats and Patristocrats.  I will be adding a lot more as time progresses.  I&#8217;m still learning so I&#8217;ll add my techniques as I learn them.  If you have any suggestions or different techniques that could be added, please leave a comment or contact me.  I&#8217;m always open for suggestions.  If you are familiar with my previous interactive solver, then the interface will be very similar.  This time there is an integrated help menu available on the right side of the screen that explains all the commands.  The interface is mostly keyboard driven as changes can be made more quickly with the keyboard than the mouse.  This allows many different types of ciphers to be solved in a similar interface with commands that are specially designed for them.
</p>
<h2>Quick Overview</h2>
<p>
<img src="/wp-content/uploads/2010/06/websolver_load.jpg" alt="Web Solver: Loading Screen" title="Web Solver: Loading Screen" width="278" height="208" class="alignleft size-full wp-image-522" /><br />
Lets run through a quick session of using the Web Solver.  I&#8217;m going to grab the A-2 cipher from the <a href="http://cryptogram.org/sample.html">sample issue of the Cryptogram</a>.  When you first open the Web Solver for the first time, it should automatically show you the &#8220;Load&#8221; Screen.  This screen can be accessed at any time by clicking the load button on the right hand side of the screen.  The help button is also in that same area providing a handy command reference and usage guide.  I&#8217;m going to paste/type in the A-2 cipher text into the text area on the loading screen and then click the &#8220;Start Solving!&#8221; button.
</p>
<p>
Note: As we go through a few examples of commands, they will be displayed in little terminal boxes in this article for display and usage purposes.  Images would be too small and you wouldn&#8217;t be able to copy and paste from them.  So just be aware that the look will be simulated but pretty close to what the real Web Solver looks like.
</p>
<p>
For all the cipher types there are three main commands: <em>clear, display, and pattern</em>. <em>Clear</em> just clears the screen in case you want to remove the clutter.  <em>Display</em> (shortcut: d) displays the current state of the cipher.  This generally will display both the ciphertext and the current state of the plaintext.  Since all cipher types are different, the display will vary depending on the type.  For example: Aristocrats will have word spacings while Patristocrats will be broken into five letter groups.  Lets check out what the display command looks like for our current con.
</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">Aristocrat Solver loaded.
&gt; d
OB ISZDPH *GQG EFBE KZE NZUZPJ SQQO ZE EQ EOFNN AKFA BQT YFP'A EKQTA
-- ------ *--- ---- --- ------ ---- -- -- ----- ---- --- ---'- -----
&nbsp;
FA AKD YFA VZAKQTA JDAAZPJ F OQTAKITN QI KFZS.
-- --- --- ------- ------- - -------- -- ----.
&gt;</pre></div></div>

<h2>Useful commands</h2>
<p>
Now that we can see our ciphertext, lets take a look some patterns.  The <em>patterns</em> command (shortcut: p) can be used to quickly look up a pattern and return any words that match it.  This command is pretty powerful so definitely read the help on it for more information.  Lets just look at a quick example.  We&#8217;ll take at a few examples from the con:
</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt; p ISZDPH
389 matches found.
absurd acting action admire adults advice advise agency agents aliens almost amount
angels answer anyhow around asking author awhile backed backup barely basket beacon
beauty begins behalf behind beings belong betray beyond bishop blocks blonde bodies
boring bother bought brains breaks breast breath bridge bright brings broken budget
burden buried burned busted buster buying campus candle caring carpet casino castle
caught caused chairs change chapel charge chosen cipher claims client closed closer
closet column comedy coming counts county couple course cousin covers coward credit
crimes cruise crying custom dancer danger dating deacon demons denial deputy design
detail direct double doubts
290 words not shown.
&nbsp;
&gt; p OQTAKITN
5 matches found.
adoption handling partners patients ultimate
&nbsp;
&gt; p JDAAZPJ
1 match found.
getting</pre></div></div>

<p>
Notice that you can grab the words directly from the ciphertext.  You can also search for number based patterns and use filters to narrow down the results.  There are four different word lists currently available with varying amounts of words.  You can switch to a different word list at any time.  We&#8217;ll use the <em>set</em> (shortcut: t) command to set the plaintext letters for one of the pattern words that we just found.
</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt; s JDAAZPJ getting
OB ISZDPH *GQG EFBE KZE NZUZPJ SQQO ZE EQ EOFNN AKFA BQT YFP'A EKQTA
-- --ien- *--- ---- -i- -i-ing ---- i- -- ----- t--t --- --n't ----t
&nbsp;
FA AKD YFA VZAKQTA JDAAZPJ F OQTAKITN QI KFZS.
-t t-e --t -it---t getting - ---t---- -- --i-.</pre></div></div>

<p>
The <em>set</em> command will except full words or single letters. You can even reset a letter by only giving a ciphertext letter. (Example: s X).  Now that we have some letters we can narrow down one of our previous pattern searches that had 389 matches.
</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt; p ISZDPH --ien-
3 matches found.
aliens client friend</pre></div></div>

<p>
That looks much better.  These filters can be used to quickly narrow down the results.  You can even use wild cards if you don&#8217;t know exact lengths.
</p>
<p>
If you want to see the frequency chart, you can use the <em>frequency</em> command (shortcut: f).  It can even give you digraphs and trigraphs if you give it a length.
</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt; f
A:12 Q:9 Z:8 F:8 E:7 K:7 T:5 O:4 P:4 N:4 B:3 I:3 S:3 D:3 J:3 G:2 Y:2 H:1 U:1 V:1
&nbsp;
&gt; f 2
AK:4 QT:4 FA:3 TA:3 ZE:2 ZP:2 PJ:2 KF:2 YF:2 KQ:2
&nbsp;
&gt; f 3
QTA:3 ZPJ:2 KQT:2</pre></div></div>

<p>
These are only a few of the commands that are available.  The help system will give you details for everything with examples.  If you have any ideas for new commands, just let me know.  They can be easily added and then everyone can have access to new solving techniques.
</p>
<h2>Save and Continue</h2>
<p>
Ever been solving a cipher and had to go do something else?  Maybe your computer crashed?  The Web Solver will automatically save your progress and allow you to come right back where you were as long as you&#8217;re using the same computer.  All the data is stored locally on your computer.
</p>
<h2>Command History</h2>
<p>
Web Solver will keep the history of the last 25 commands that you have used.  You can go back through them by pressing up and down.  This way you can save some typing if you want to go back to a previously used command.
</p>
<h2>Conclusion</h2>
<p>
Web Solver is a solving tool.  It won&#8217;t do all the work for you but hopefully it will make things easier.  <strong>It is available now at <a href="http://tools.codepenguin.com/websolver/">http://tools.codepenguin.com/websolver/</a>.</strong> Please, let me know what you think.  Leave a comment or <a href="/contact-me/">contact me</a> directly.   I love to hear your ideas and suggestions.  I will continue to improve Web Solver and add new features as time goes on.
</p>
<h2>Technical Details and Links</h2>
<p>
For those interested, I&#8217;d like to mention the different technologies and techniques that made this possible.</p>
<ul>
<li><a href="http://jquery.com/">jQuery</a> &#8211; A powerful javascript library that makes cross-platform web development a whole lot easier.  This is pretty much the core of the entire implementation.</li>
<li><a href="http://taffydb.com/">Taffy DB</a> &#8211; A JavaScript library that acts as an in memory data layer.  This powers the CP List which is a small embedded word list.  All the other word lists require an external database connection.  CP List can be used without an internet connection.</li>
<li><a href="http://wonko.com/post/lazyload-200-released">LazyLoad</a> &#8211; A JavaScript library used to load files dynamically only when needed.  This is used to load the word list functionality on the fly without taking up a lot of memory.</li>
<li><a href="http://pablotron.org/?cid=1557">PersistJS</a> &#8211; A JavaScript library that provides client-side persistent storage.  This handles all the storage needs and works great in all modern browsers.</li>
<li><a href="http://spyrestudios.com/how-to-create-a-sexy-vertical-sliding-panel-using-jquery-and-css3/">How To Create A Sexy Vertical Sliding Panel Using jQuery And CSS3</a> &#8211; This tutorial helped me create the sliding Load and Help panels.</li>
</ul>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/5kTPAioAdJM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2010/06/19/websolver-an-interactive-cryptogram-solver-for-the-web/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2010/06/19/websolver-an-interactive-cryptogram-solver-for-the-web/</feedburner:origLink></item>
		<item>
		<title>Pattern Words: A Solver's Staple</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/AWIxXeAEsbQ/</link>
		<comments>http://www.codepenguin.com/2010/06/11/pattern-words-a-solvers-staple/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 05:08:49 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[ACA]]></category>
		<category><![CDATA[aristocrat]]></category>
		<category><![CDATA[cryptograms]]></category>
		<category><![CDATA[patristocrat]]></category>

		<guid isPermaLink="false">http://www.codepenguin.com/?p=460</guid>
		<description><![CDATA[While working on the Beginner&#8217;s Guide to the ACA, there was one technique that consistently showed up in all the research material: Pattern Words! At first I didn&#8217;t really understand how great they were. For those who don&#8217;t know about them or need a refresher, I&#8217;ll discuss a few of the different pattern types that [...]]]></description>
			<content:encoded><![CDATA[<p>
While working on the <a href="/2010/06/06/beginners-guide-to-the-aca/">Beginner&#8217;s Guide to the ACA</a>, there was one technique that consistently showed up in all the research material:  Pattern Words!  At first I didn&#8217;t really understand how great they were.  For those who don&#8217;t know about them or need a refresher, I&#8217;ll discuss a few of the different pattern types that I have come across.   Afterwards,  I&#8217;ll discuss my own Pattern Word Search Tool.  Lets get started!
</p>
<p><span id="more-460"></span></p>
<h2>Pattern Types</h2>
<h4>Fixed Length Patterns</h4>
<p>
Pattern words have one or more letters that are repeated. These repeated letters provide a clue to the word&#8217;s identity. Start by taking a word and assigning numbers to each letter starting at the left with 1 . Use the same number for repeated letters. Now you can look for the number based pattern in a pattern word list to see which words match the pattern.  I call these the &#8220;Fixed Length Patterns&#8221;.</p>
<p>Common pattern words worth memorizing:
</p>
<pre>
1231    123142    12342
that    people    which

122     12343     123314
all     there     little
off     these
see     where
too
</pre>
<h4>Floating Length Patterns</h4>
<p>
While researching pattern words I came across a few other pattern types that are useful also.  <a href="http://www.codasaurus.com/pattern.htm">Codasaurus.com</a> mentioned a shorted version of the above numeric pattern that only shows the repeated characters.  I call these the &#8220;Floating Length Patterns&#8221;.  These are great when you don&#8217;t know the full length of the word.  First calculate the pattern as above. Then, starting at the front, write down all the positions of the first duplicated letter. Continue this process for all other duplicated letters. This form can be useful when you don&#8217;t know the exact length of a word or when multiple word endings are possible. The above examples would be as follows using this method:
</p>
<pre>
14      1426      25
that    people    which

23      35        1534
all     there     little
off     these
see     where
too
</pre>
<h4>High/Low Frequency Patterns</h4>
<p>
In the comments on my article <a href="/2009/02/01/social-cryptogram-solving/#comment-7">Social Cryptogram Solving</a>, BOATTAIL mentioned patterns that looked at the frequency of letters. Using a frequency table you can determine which letters are high and low frequency letters. Then replace the letters with H for high and L for low.  For English, the high frequency letters are ETAONIRSH.  The examples from above would look as follows:
</p>
<pre>
HHHH    LHHLLH    LHHLH
that    people    which

HLL     HHHHH     LHHHLH
all     there     little
off     these
see     where
too
</pre>
<h2>Searching for Pattern Words</h2>
<p>
You can find pattern word lists on the internet by just searching for them.  Most of the time they are a little hard to handle for beginners because they usually come in raw text files and they generally just contain the fixed length patterns.  I&#8217;ve created a special website that will allow you to search for any of the patterns discussed above in a few different word lists.   At the moment I have three different word lists that are searchable.   They each have their own strengths and weaknesses.  You can access it at <a href="http://tools.codepenguin.com/patterns/">http://tools.codepenguin.com/patterns/</a>.  The page has instructions for how to use each of the different patterns above and how to apply word filters to weed out the possibilities.
</p>
<p>
Depending on the word list used, pattern words become less useful simply because they return too many words.  That is where the word filters come into play.  With word filters, you can shrink the matches for the patterns down to ones that fit your needs.  For example:  if you look up the pattern 1426 (for people) in the ENABLE2K word list, it returns 130 words.  If you know that the first and fourth letters are &#8220;p&#8221; you can use the filter &#8220;p..p*&#8221; the matches drop down to 24 words.  24 is much more manageable and realistic.
</p>
<p>
 If you find my pattern search tool useful, <a href="/contact-me/">please let me know</a>.  I&#8217;m always open for suggestions on how to improve my tools and for new ideas.
</p>
<h2>Conclusion</h2>
<p>
All the different kinds of patterns give you a lot of techniques to aid in solving Aristocrats and Patristocrats.  You can get quite far by using them.  Pattern word lists are available on the internet and there are some published books that have them too.  They are an essential tool for any solver&#8217;s tool box.</p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/AWIxXeAEsbQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2010/06/11/pattern-words-a-solvers-staple/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2010/06/11/pattern-words-a-solvers-staple/</feedburner:origLink></item>
		<item>
		<title>Beginner's Guide to the ACA</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/juGz0o9buVM/</link>
		<comments>http://www.codepenguin.com/2010/06/06/beginners-guide-to-the-aca/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 03:32:09 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[ACA]]></category>
		<category><![CDATA[aristocrat]]></category>
		<category><![CDATA[cryptograms]]></category>
		<category><![CDATA[patristocrat]]></category>

		<guid isPermaLink="false">http://www.codepenguin.net/?p=425</guid>
		<description><![CDATA[When I first joined the ACA and opened my starter packet, I was eager to jump right in and start solving Aristocrats and Patristocrats. I tried to solve as many as I could. Once I got stuck I would try to learn a different way to solve in hopes that it would get me unstuck. [...]]]></description>
			<content:encoded><![CDATA[<p>When I first joined the <a href="http://www.cryptogram.org">ACA</a> and opened my starter packet, I was eager to jump right in and start solving Aristocrats and Patristocrats.  I tried to solve as many as I could.  Once I got stuck I would try to learn a different way to solve in hopes that it would get me unstuck.  There is so much great information available on solving different cipher types and trying out new techniques.  Unfortunately, since there is so much great information, it is difficult to figure out where to start or what resources to use.  I found myself frequently getting lost in material too advanced at the early stage and becoming quite frustrated when the information did not penetrate my thick skull.</p>
<p>After one frustrating week, I contacted LIONEL, the ACA Recruitment Committee chairman, in hopes of finding some form of beginner&#8217;s guide to help me stay focused.  He mentioned the <a href="http://cryptogram.org/cdb/aca.info/tyros/index.html">&#8220;Young Tyros Newsletter&#8221;</a>.  It is a wonderful resource and I really recommend all new members and even non-members to read them.  They have lots of great insights and tips to get you unstuck.  In our discussions, I proposed that we should create a &#8220;Beginner&#8217;s Guide to the ACA&#8221;.  I definitely didn&#8217;t want to re-hash all the great information out there.  My goal was to compile a small list of the most important topics for a beginner to know and then point them in the right direction of all the other great materials out there.</p>
<p>LIONEL put me in contact with a few members who graciously agreed to send me some of their notes on how they solved some of the lower level Aristocrat and Patristocrat cons.  Their notes and insights have been a great help in increasing my knowledge and solving abilities.   It took quite a long time and many iterations before I was satisfied with it but I finally finished the first version of the &#8220;Beginner&#8217;s Guide to the ACA!&#8221;  This would not have been possible without the help of BECASSE, GGMA, LIONEL, MICROPOD, MATANZA, and ZANAC.  I am very grateful for their help.</p>
<p>You can download the Beginner&#8217;s Guide to the ACA below.  Hopefully, it&#8217;ll help someone not get frustrated and lose interest in cryptology before they gave it a good chance.</p>
<p><a href='/wp-content/uploads/2010/06/aca_beginners_guide.pdf'><img src="/wp-content/uploads/2010/06/aca_beginners_guide.jpg" alt="Beginner&#039;s Guide to the ACA Screen Shot" title="Beginner&#039;s Guide to the ACA Screen Shot" width="300" height="424" class="aligncenter size-full wp-image-426" /></a><br />
<center><a href='/wp-content/uploads/2010/06/aca_beginners_guide.pdf'>Click here to download!</a></center></p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/juGz0o9buVM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2010/06/06/beginners-guide-to-the-aca/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2010/06/06/beginners-guide-to-the-aca/</feedburner:origLink></item>
		<item>
		<title>Quartus II Quick Start</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/Phww8ENTTlE/</link>
		<comments>http://www.codepenguin.com/2010/02/08/quartus-ii-quick-start/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 03:12:29 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[Random Thoughts]]></category>

		<guid isPermaLink="false">http://www.codepenguin.net/?p=383</guid>
		<description><![CDATA[I&#8217;m taking a Computer Engineering Course and Lab and have been learning how to use the software Quartus II to generate and test logic circuit schematics. The tutorial given in the class was quite long so it was hard to fully retain all the information and quickly find anything if I forgot a step. I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m taking a Computer Engineering Course and Lab and have been learning how to use the software <a href="http://www.altera.com/products/software/quartus-ii/web-edition/qts-we-index.html">Quartus II</a> to generate and test logic circuit schematics.  The tutorial given in the class was quite long so it was hard to fully retain all the information and quickly find anything if I forgot a step.  I went through the tutorial and wrote down a few helpful steps and thought I would share it.</p>
<p><center><a href='/wp-content/uploads/2010/02/Quartus2QuickStart.pdf'><img src="/wp-content/uploads/2010/02/QuartusQuickStart.jpg" alt="QuartusQuickStart" title="QuartusQuickStart" width="234" height="302" class="size-full wp-image-385" /><br/>Quartus II Quick Start</a></center></p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/Phww8ENTTlE" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2010/02/08/quartus-ii-quick-start/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2010/02/08/quartus-ii-quick-start/</feedburner:origLink></item>
		<item>
		<title>Creating an interactive cryptogram solver (Part IV)</title>
		<link>http://feedproxy.google.com/~r/codepenguin/SpFe/~3/qFmMBbSDTV4/</link>
		<comments>http://www.codepenguin.com/2009/10/31/creating-an-interactive-cryptogram-solver-part-iv/#comments</comments>
		<pubDate>Sun, 01 Nov 2009 03:40:25 +0000</pubDate>
		<dc:creator>David Lambert</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[ACA]]></category>
		<category><![CDATA[aristocrat]]></category>
		<category><![CDATA[cryptograms]]></category>
		<category><![CDATA[patristocrat]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[solver]]></category>

		<guid isPermaLink="false">http://www.codepenguin.net/?p=327</guid>
		<description><![CDATA[I&#8217;ve been working hard on this part of the series because I really wanted the interactive cryptogram solver to make it quick and painless to jump right into solving and still give you plenty of room to expand the functionality and reflect your own style of solving. In this part of the series, we will [...]]]></description>
			<content:encoded><![CDATA[<p><img class="size-full wp-image-79  alignright" title="Execute Interactive Solver" src="/wp-content/uploads/2009/09/Solver.png" alt="Execute Interactive Solver" width="477" height="64" /></p>
<p>I&#8217;ve been working hard on this part of the series because I really wanted the interactive cryptogram solver to make it quick and painless to jump right into solving and still give you plenty of room to expand the functionality and reflect your own style of solving.  In this part of the series, we will create solver.py which will become our gateway to solving.  It will allow us to quickly select a cipher class that we want to work with.  We will also add a self documenting system that will allow us to use the solver without memorizing all the commands or shortcuts that each solver class may use.  So, lets just jump right back into the code!</p>
<p><span id="more-327"></span></p>
<h4>Clearing the screen</h4>
<p>While we are using the solver, it is a common place for the screen to get a little crowded.  So lets add a new function to our shared.py that will take care of clearing the screen.  Clearing the screen is a little complicated because each operating system has it&#8217;s own way of handling it.  Our <em>clear_screen</em> function will handle all the major players: Windows, Mac, and Linux.</p>
<p class="wp-caption">Contents of shared.py (Place at the bottom of the file)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> clear_screen<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
  <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">name</span> == <span style="color: #483d8b;">&quot;posix&quot;</span>:using the
      <span style="color: #808080; font-style: italic;"># Unix/Linux/MacOS/BSD/etc</span>
      <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'clear'</span><span style="color: black;">&#41;</span>
  <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">name</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;nt&quot;</span>, <span style="color: #483d8b;">&quot;dos&quot;</span>, <span style="color: #483d8b;">&quot;ce&quot;</span><span style="color: black;">&#41;</span>:
      <span style="color: #808080; font-style: italic;"># DOS/Windows</span>
      <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'CLS'</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>All we are really doing here is importing the <em>os</em> and using the <em>os.name</em> to tell which operating system we are in and then executing the appropriate command for clearing the screen.</p>
<h4>The Solving Gateway: solver.py</h4>
<p>I call <em>solver.py</em> the gateway because this is really the file that you will be executing the most.  Everytime we create a new class based on <em>CipherSolver</em>, we&#8217;ll want to import it into <em>solver.py</em> so we can access it.  I&#8217;ll show you how to do that in just a minute.  First, lets just show the entire contents of <em>solver.py</em> and then we&#8217;ll go through the good parts. </p>
<p class="wp-caption">Contents of solver.py</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> shared
<span style="color: #ff7700;font-weight:bold;">from</span> cipher <span style="color: #ff7700;font-weight:bold;">import</span> CipherSolver
<span style="color: #ff7700;font-weight:bold;">from</span> aristocrat <span style="color: #ff7700;font-weight:bold;">import</span> AristocratSolver
<span style="color: #ff7700;font-weight:bold;">from</span> patristocrat <span style="color: #ff7700;font-weight:bold;">import</span> PatristocratSolver
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
  solvers = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
  <span style="color: #ff7700;font-weight:bold;">for</span> name, obj <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">items</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> name.<span style="color: black;">endswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Solver&quot;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">issubclass</span><span style="color: black;">&#40;</span>obj, CipherSolver<span style="color: black;">&#41;</span>:
      solvers<span style="color: black;">&#91;</span>name<span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> = obj
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
    shared.<span style="color: black;">clear_screen</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;-&quot;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">37</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;    Interactive Cryptogram Solver&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;-&quot;</span> <span style="color: #66cc66;">*</span> <span style="color: #ff4500;">37</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Type a cipher type or partial (q to quit) [all]: &quot;</span>,
    <span style="color: #dc143c;">cmd</span> = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;q&quot;</span>,<span style="color: #483d8b;">&quot;quit&quot;</span><span style="color: black;">&#93;</span>:
      <span style="color: #ff7700;font-weight:bold;">break</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
      <span style="color: #008000;">list</span> = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
      <span style="color: #ff7700;font-weight:bold;">for</span> name, obj <span style="color: #ff7700;font-weight:bold;">in</span> solvers.<span style="color: black;">items</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> name.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>:
          <span style="color: #008000;">list</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>name<span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
        <span style="color: #008000;">list</span>.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> index <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>:
          <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;  {0}. {1}&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>index, <span style="color: #008000;">list</span><span style="color: black;">&#91;</span>index-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Type number of selection or return to go back: &quot;</span>,
        <span style="color: #dc143c;">cmd</span> = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span>.<span style="color: black;">isdigit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span>= <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:
          name = <span style="color: #008000;">list</span><span style="color: black;">&#91;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
          <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Loaded {0} Solver.&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>name<span style="color: black;">&#41;</span>
          solvers<span style="color: black;">&#91;</span>name<span style="color: black;">&#93;</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">solve</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;</span></pre></td></tr></table></div>

<p>The first few lines are essentially the most important part of this file.  They import all the <em>CipherSolver</em> classes that we want available.  You only need to import the your Solver classes, not the Cipher classes.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>2
3
4
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">from</span> cipher <span style="color: #ff7700;font-weight:bold;">import</span> CipherSolver
<span style="color: #ff7700;font-weight:bold;">from</span> aristocrat <span style="color: #ff7700;font-weight:bold;">import</span> AristocratSolver
<span style="color: #ff7700;font-weight:bold;">from</span> patristocrat <span style="color: #ff7700;font-weight:bold;">import</span> PatristocratSolver</pre></td></tr></table></div>

<p>Right now we only have three classes to import.  We have to import the <em>CipherSolver</em> class because everything is based on that one.  This is where you would include any other Solver classes that you create.  The pattern is:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"> <span style="color: #ff7700;font-weight:bold;">from</span> FILENAME <span style="color: #ff7700;font-weight:bold;">import</span> SOLVERCLASS</pre></div></div>

<p>Just add any new ones below the <em>PatristocratSolver</em> line.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>6
7
8
9
10
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
  solvers = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
  <span style="color: #ff7700;font-weight:bold;">for</span> name, obj <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">globals</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">items</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> name.<span style="color: black;">endswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Solver&quot;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">issubclass</span><span style="color: black;">&#40;</span>obj, CipherSolver<span style="color: black;">&#41;</span>:
      solvers<span style="color: black;">&#91;</span>name<span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">6</span><span style="color: black;">&#93;</span><span style="color: black;">&#93;</span> = obj</pre></td></tr></table></div>

<p>Line 6 is an interesting line of code that you may have seen in other Python files.  Python files can be executed on their own or imported from other Python files as we have seen above.  One problem that arises is that python tries to execute all lines that are in the file as it is imported.  But what if we want to execute code only when our file is executed on its own?  That is exactly what this line of code does.  It essentially says &#8220;If this file is being executed on its own and not imported, then do the following:&#8221;.  Anything indented below the &#8220;if statement&#8221; will only be executed when we type:
</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">python solver.py</pre></div></div>

<p>The rest of the lines in this section walks through all the imported classes and functions in the <em>globals</em> dictionary.  Whenever we use the <em>import</em> command, the things we import get stored in the <em>globals</em> dictionary.  So here we are scanning <em>globals</em> and pulling out any classes that are based off of our <em>CipherSolver</em> class.  We&#8217;ll store all the classes and their names so we can use them later.</p>
<p>Note:  I&#8217;m going to warn you right now, this part of the series contains a lot of code that is purely just for display purposes.  We&#8217;ll be formatting a lot of things things to display on the screen.  I won&#8217;t go over every line in these cases.  Just know that if you see &#8220;print&#8221; or &#8220;output&#8221; then those are things that will be displayed or eventually displayed. </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #dc143c;">cmd</span> = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;q&quot;</span>,<span style="color: #483d8b;">&quot;quit&quot;</span><span style="color: black;">&#93;</span>:
      <span style="color: #ff7700;font-weight:bold;">break</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
      <span style="color: #008000;">list</span> = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
      <span style="color: #ff7700;font-weight:bold;">for</span> name, obj <span style="color: #ff7700;font-weight:bold;">in</span> solvers.<span style="color: black;">items</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> name.<span style="color: black;">lower</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>:
          <span style="color: #008000;">list</span>.<span style="color: black;">append</span><span style="color: black;">&#40;</span>name<span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&gt;</span> <span style="color: #ff4500;">0</span>:
        <span style="color: #008000;">list</span>.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">for</span> index <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>,<span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>:
          <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;  {0}. {1}&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>index, <span style="color: #008000;">list</span><span style="color: black;">&#91;</span>index-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Type number of selection or return to go back: &quot;</span>,
        <span style="color: #dc143c;">cmd</span> = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span>.<span style="color: black;">isdigit</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span> <span style="color: #66cc66;">&lt;</span> <span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">&lt;</span>= <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:
          name = <span style="color: #008000;">list</span><span style="color: black;">&#91;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
          <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>Loaded {0} Solver.&quot;</span>.<span style="color: black;">format</span><span style="color: black;">&#40;</span>name<span style="color: black;">&#41;</span>
          solvers<span style="color: black;">&#91;</span>name<span style="color: black;">&#93;</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">solve</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;</span></pre></td></tr></table></div>

<p>Here we prompt the user to type in the name or part of a name of the class that they would like to use.  We then walk through our list of Solver classes and display any that match the inputted name and display them on the screen.  The user then gets to type the number that corresponds with the class on the screen.  You can also just press enter to get a list of all available classes.  Lets see what the looks like when we run it.</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">python solver.py
-------------------------------------
    Interactive Cryptogram Solver
-------------------------------------
Type a cipher type or partial (q to quit) [all]:</pre></div></div>

<p>Lets just press enter here to see all the classes that are loaded:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">  1. Aristocrat
  2. Cipher
  3. Patristocrat
Type number of selection or return to go back:</pre></div></div>

<p>If we type &#8220;3&#8243; to select Patristocrat and then press enter we get the following:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">Type number of selection or return to go back:  3
&nbsp;
Loaded Patristocrat Solver.
&gt;</pre></div></div>

<p>Now we are ready to solve a Patristocrat!  Our <em>PatristocratSolver</em> class is automatically loaded and executed.  If we want to go back to the selection screen we can just press Ctrl+C at any time.</p>
<h4>The Documentation System</h4>
<p>I don&#8217;t know about you but I have a major problem remembering things sometimes.  I even have a T-Shirt that says &#8220;Insufficient Memory&#8221; on it.  So if we create a new solver class for the over sixty different cipher types used in the Cryptogram, there is no way I could remember all the different commands and functions that we would need.  It would be very beneficial for us to have documentation on all the different classes we use and to be able to display it whenever we need to. I&#8217;m not the greatest at writing documentation especially when the code can change so quickly.  So our documentation system would have to be easy to update and not super complicated.  Alright, here we go.  We are going to put the documentation into the <em>CipherSolver</em> class so most of our changes are going to be in the cipher.py file.</p>
<p class="wp-caption">Contents of cipher.py (Add at the top on line 4)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>4
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">inspect</span>,<span style="color: #dc143c;">types</span></pre></td></tr></table></div>

<p>Here we are importing two modules.  The <em>inspect</em> module is going to be the core of our documentation. The python documentation describes this module as:</p>
<blockquote><p>inspect &#8211; Get useful information from live Python objects.</p></blockquote>
<p>This module can give you all sorts of information about our classes and objects.  We&#8217;ll see how its used in a minute.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>30
31
32
33
34
35
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> CipherSolver<span style="color: black;">&#40;</span><span style="color: #008000;">object</span><span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span> = Cipher<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">prompt</span> = <span style="color: #483d8b;">&quot;&gt;&quot;</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">maxlinelen</span> = <span style="color: #ff4500;">70</span>
    <span style="color: #008000;">self</span>.<span style="color: black;">shortcuts</span> = <span style="color: black;">&#123;</span><span style="color: #483d8b;">&quot;?&quot;</span>:<span style="color: #483d8b;">&quot;_display_help&quot;</span>,<span style="color: #483d8b;">&quot;d&quot;</span>:<span style="color: #483d8b;">&quot;display&quot;</span><span style="color: black;">&#125;</span></pre></td></tr></table></div>

<p>The above code is just slightly different from Part III.  We are now telling the <em>CipherSolver</em> that it should inherit from the <em>object</em> class.  This is the new style of classes in python and just makes sure our code will work in future version of python and that all the special python modules that use objects will work correctly.  We also add a new shortcut on line 35.  This shortcut lets us type &#8220;?&#8221; at any time to activate our help system by calling the <em>_display_help</em> function.</p>
<p>One thing to note here, any function that starts with a &#8220;_&#8221; will be hidden from the documentation system.  They won&#8217;t be displayed.  This allows you to add helper functions that are not available for calling directly.  Lets add a few of these little helper functions. (I&#8217;m going to go a little out of order here.  If you want to see the cipher.py file in its correct order, view the source at the end of this article.)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>55
56
57
58
59
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> _inherit_docs<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, BaseClass<span style="color: black;">&#41;</span>:
    members = <span style="color: #dc143c;">inspect</span>.<span style="color: black;">getmembers</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">inspect</span>.<span style="color: black;">ismethod</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> name, method <span style="color: #ff7700;font-weight:bold;">in</span> members:
      <span style="color: #ff7700;font-weight:bold;">if</span> method.__doc__ == <span style="color: #008000;">None</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span>BaseClass, name<span style="color: black;">&#41;</span>:
        method.<span style="color: black;">im_func</span>.__doc__ = <span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span>BaseClass, name<span style="color: black;">&#41;</span>.__doc__</pre></td></tr></table></div>

<p>The <em>_inherit_docs</em> function will walk through all the different overridden functions in our classes and make sure they have their own documentation or use the documentation from the base class.  This may sounds confusing at first but we&#8217;ll show actual code examples later.  Simply put, since all our classes are going to have a <em>display</em> function that just does things a little different for each class, why should we have to repeat the documentation each time?  In our documentation system, the <em>PatristocratSolver</em> will look at the <em>AristocratSolver</em> for its documentation and the <em>AristocratSolver</em> will look at <em>CipherSolver</em> for its documentation.  Lets add those calls right now.  Add the following to the aristocrat.py and patristocrat.py.</p>
<p class="wp-caption">Contents of aristocrat.py (Add to the AristocratSolver.__init__ method)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>44
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #008000;">self</span>._inherit_docs<span style="color: black;">&#40;</span>CipherSolver<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p class="wp-caption">Contents of patristocrat.py (Add to the PatristocratSolver.__init__ method)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>15
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #008000;">self</span>._inherit_docs<span style="color: black;">&#40;</span>AristocratSolver<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>We need to make one major modification to the <em>CipherSolver.solve</em> method.  In the previous parts of this series, we made the <em>solve</em> method handle any methods that are part of the solver class and the cipher class.  Our modification is going to change this to only go through the solver class.  This might sound like a disadvantage at first, but it will make our solver much more powerful in the end.  Change your solve method to the following:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> solve<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
      <span style="color: #ff7700;font-weight:bold;">try</span>:
        raw_line = <span style="color: #008000;">raw_input</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.<span style="color: black;">prompt</span> + <span style="color: #483d8b;">&quot; &quot;</span><span style="color: black;">&#41;</span>
        line = <span style="color: #dc143c;">re</span>.<span style="color: black;">findall</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\'</span>[^<span style="color: #000099; font-weight: bold;">\'</span>]*<span style="color: #000099; font-weight: bold;">\'</span>|<span style="color: #000099; font-weight: bold;">\&quot;</span>[^<span style="color: #000099; font-weight: bold;">\&quot;</span>]*<span style="color: #000099; font-weight: bold;">\&quot;</span>|<span style="color: #000099; font-weight: bold;">\S</span>+'</span>, raw_line<span style="color: black;">&#41;</span>
        line = <span style="color: black;">&#91;</span>item<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">if</span> item<span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #483d8b;">'<span style="color: #000099; font-weight: bold;">\'</span>&quot;'</span> <span style="color: #ff7700;font-weight:bold;">else</span> item <span style="color: #ff7700;font-weight:bold;">for</span> item <span style="color: #ff7700;font-weight:bold;">in</span> line<span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;</span>
        <span style="color: #dc143c;">cmd</span> = line.<span style="color: black;">pop</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#41;</span>
        attr = <span style="color: #008000;">None</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">shortcuts</span>:
          <span style="color: #dc143c;">cmd</span> = <span style="color: #008000;">self</span>.<span style="color: black;">shortcuts</span><span style="color: black;">&#91;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span>.<span style="color: black;">endswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;?&quot;</span><span style="color: black;">&#41;</span>:
          <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #008000;">self</span>._display_help<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
          <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;solve&quot;</span>:
            attr = <span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
          <span style="color: #ff7700;font-weight:bold;">if</span> attr == <span style="color: #008000;">None</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Unknown command: &quot;</span>, <span style="color: #dc143c;">cmd</span>
          <span style="color: #ff7700;font-weight:bold;">else</span>:
            retvalue = <span style="color: #008000;">None</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">type</span><span style="color: black;">&#40;</span>attr<span style="color: black;">&#41;</span> == <span style="color: #dc143c;">types</span>.<span style="color: black;">MethodType</span>:
                retvalue = attr<span style="color: black;">&#40;</span><span style="color: #66cc66;">*</span>line<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">else</span>:
              <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>line<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">0</span>:
                retvalue = attr
              <span style="color: #ff7700;font-weight:bold;">else</span>:
                <span style="color: #008000;">setattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">cmd</span>, <span style="color: #66cc66;">*</span>line<span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">if</span> retvalue <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span>:
              <span style="color: #ff7700;font-weight:bold;">print</span> retvalue
          <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;</span>
      <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">KeyboardInterrupt</span>:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Exiting Solver&quot;</span>
        <span style="color: #ff7700;font-weight:bold;">break</span>
      <span style="color: #ff7700;font-weight:bold;">except</span> <span style="color: #008000;">Exception</span>, e:
        <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Error: &quot;</span>, e</pre></td></tr></table></div>

<p>The big change here is that we first check to see if the command ends with a question mark.  If so, it will pass the command, minus the question mark, to the <e>_display_help</em> function that we&#8217;ll discuss in a minute.  We also add the support to get and set a properties that are defined in the class.</p>
<p>Now comes the entire documentation system.  Its all bundled in a special function called <em>_display_help</em>.  Now be prepared, this is a long function.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> _display_help<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, <span style="color: #dc143c;">cmd</span>=<span style="color: #008000;">None</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">shortcuts</span>:
      <span style="color: #dc143c;">cmd</span> = <span style="color: #008000;">self</span>.<span style="color: black;">shortcuts</span><span style="color: black;">&#91;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#93;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> _get_function_def<span style="color: black;">&#40;</span>name,function<span style="color: black;">&#41;</span>:
      specs = <span style="color: #dc143c;">inspect</span>.<span style="color: black;">getargspec</span><span style="color: black;">&#40;</span>function<span style="color: black;">&#41;</span>
      defaults = <span style="color: #008000;">None</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> specs.<span style="color: black;">defaults</span>:
        defaults = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: #008000;">zip</span><span style="color: black;">&#40;</span>specs.<span style="color: black;">args</span><span style="color: black;">&#91;</span>-<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>specs.<span style="color: black;">defaults</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span>,specs.<span style="color: black;">defaults</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
      output = name
      <span style="color: #ff7700;font-weight:bold;">for</span> arg <span style="color: #ff7700;font-weight:bold;">in</span> specs.<span style="color: black;">args</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> arg <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">'self'</span>:
          output += <span style="color: #483d8b;">&quot; &quot;</span> + arg
          <span style="color: #ff7700;font-weight:bold;">if</span> defaults <span style="color: #ff7700;font-weight:bold;">and</span> arg <span style="color: #ff7700;font-weight:bold;">in</span> defaults:.  <span style="color: black;">I</span>
            output += <span style="color: #483d8b;">&quot;=&quot;</span> + <span style="color: #dc143c;">repr</span><span style="color: black;">&#40;</span>defaults<span style="color: black;">&#91;</span>arg<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">return</span> output.  <span style="color: black;">I</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> _display_doc<span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span>:
      doc = <span style="color: #483d8b;">&quot;&quot;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">inspect</span>.<span style="color: black;">getdoc</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">inspect</span>.<span style="color: black;">getdoc</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#41;</span>:
          doc += <span style="color: #483d8b;">&quot;   &quot;</span> + line + <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
        doc += <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
      <span style="color: #ff7700;font-weight:bold;">return</span> doc
&nbsp;
    cmd_shortcuts = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>v,k<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> k,v <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">shor</span>.  <span style="color: black;">Itcuts</span>.<span style="color: black;">items</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    obj = <span style="color: #008000;">None</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">cmd</span> == <span style="color: #008000;">None</span>:
      obj = <span style="color: #008000;">self</span>.__class__
    <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #008000;">hasattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.__class__,<span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>:
      obj = <span style="color: #008000;">getattr</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>.__class__,<span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
    output = <span style="color: #483d8b;">&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">inspect</span>.<span style="color: black;">isclass</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span>:
      output = obj.__name__ + <span style="color: #483d8b;">&quot;:<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
      output += _display_doc<span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span>
      member_filter = <span style="color: #ff7700;font-weight:bold;">lambda</span> obj: <span style="color: #dc143c;">inspect</span>.<span style="color: black;">ismethod</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>obj,<span style="color: #008000;">property</span><span style="color: black;">&#41;</span>
      members = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">inspect</span>.<span style="color: black;">getmembers</span><span style="color: black;">&#40;</span>obj, member_filter<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      members = <span style="color: black;">&#91;</span>name <span style="color: #ff7700;font-weight:bold;">for</span> name <span style="color: #ff7700;font-weight:bold;">in</span> members <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #ff7700;font-weight:bold;">not</span> name.<span style="color: black;">startswith</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;_&quot;</span><span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> name <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;solve&quot;</span><span style="color: black;">&#93;</span>
      members.<span style="color: black;">sort</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
      output += <span style="color: #483d8b;">&quot;  Available Commands:<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
      <span style="color: #ff7700;font-weight:bold;">for</span> index <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #008000;">len</span><span style="color: black;">&#40;</span>members<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>:
        member = members<span style="color: black;">&#91;</span>index<span style="color: black;">&#93;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> cmd_shortcuts.<span style="color: black;">get</span><span style="color: black;">&#40;</span>member<span style="color: black;">&#41;</span>:
          member += <span style="color: #483d8b;">&quot; [&quot;</span> + cmd_shortcuts.<span style="color: black;">get</span><span style="color: black;">&#40;</span>member<span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;]&quot;</span>
        output += member.<span style="color: black;">rjust</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">20</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: black;">&#40;</span>index + <span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">%</span> <span style="color: #ff4500;">3</span> == <span style="color: #ff4500;">0</span>:
          output += <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #dc143c;">inspect</span>.<span style="color: black;">ismethod</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #dc143c;">cmd</span> <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">&quot;solve&quot;</span>:
      output = <span style="color: #dc143c;">cmd</span>
      shortcut = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: black;">&#40;</span>v,k<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">for</span> k,v <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">self</span>.<span style="color: black;">shortcuts</span>.<span style="color: black;">items</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> shortcut.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>:
        output += <span style="color: #483d8b;">&quot; [&quot;</span> + shortcut.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;]&quot;</span>
      output +=<span style="color: #483d8b;">&quot;:<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> + _display_doc<span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span>
      output += <span style="color: #483d8b;">&quot;   Usage:<span style="color: #000099; font-weight: bold;">\n</span>      &quot;</span> + _get_function_def<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span>, obj<span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">elif</span> <span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>obj,<span style="color: #008000;">property</span><span style="color: black;">&#41;</span>:
      output = <span style="color: #dc143c;">cmd</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> obj.<span style="color: black;">fset</span> == <span style="color: #008000;">None</span>:
        output += <span style="color: #483d8b;">&quot; (Read Only)&quot;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> cmd_shortcuts.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>:
        output += <span style="color: #483d8b;">&quot; [&quot;</span> + cmd_shortcuts.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;]&quot;</span>
      output += <span style="color: #483d8b;">&quot;:<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> + _display_doc<span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span>
      output += <span style="color: #483d8b;">&quot;   To display the value:<span style="color: #000099; font-weight: bold;">\n</span>      &quot;</span> + <span style="color: #dc143c;">cmd</span> + <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> obj.<span style="color: black;">fset</span> <span style="color: #66cc66;">!</span>= <span style="color: #008000;">None</span>:
        output += <span style="color: #483d8b;">&quot;   To change the value:<span style="color: #000099; font-weight: bold;">\n</span>      &quot;</span> + _get_function_def<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span>, obj.<span style="color: black;">fset</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
      output = <span style="color: #483d8b;">&quot;Unknown command: &quot;</span> + <span style="color: #dc143c;">cmd</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> output.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span></pre></td></tr></table></div>

<p>It looks daunting at first but is actually quite simple.  If you remove all the display code (all the output statements) this is what you&#8217;re left with: the function takes a command that you want to see the documentation for and displays it or if you pass in blank, it&#8217;ll display all the commands that are available and any shortcuts that are defined.  Ok, lets see how this works right now!  Fire up sandbox.py for now:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">python sandbox.py
&gt; ?
&nbsp;
PatristocratSolver:
&nbsp;
  Available Commands:
         display [d]  frequency_list [f]            keys [k]
        print_counts             set [s]
&nbsp;
&gt;</pre></div></div>

<p>So if we type &#8220;?&#8221; It&#8217;ll show us all the commands!  Notice that the shortcuts are listed in brackets next to the commands.  This way you can see them if you have forgotten what they are.  Now lets get back to the code.  Lets look at a few of the important parts of the <em>_display_help</em> function.</p>
<p>Did you notice that the <em>print_counts</em> function was listed in our command list from above?  That isn&#8217;t really a command that should be executed in the solver.  It&#8217;s one of those special helper functions.  Lets change its name to <em>_print_counts</em> so that it will be hidden (Note: You will need to change where it is used in aristocrat.py and patristocrat.py too or it will give you an error.).</p>
<p>Lets chop up the <em>_display_help</em> function into the three types of objects that the command passed in can represent.  First, a solver class like <em>AristocratSolver</em>. Second, a method of the class like <em>display</em>.  Third, a property of the class.</p>
<h6>Solver Classes</h6>
<p>As we saw before, if no command is passed into the function, then a summary of all available commands is displayed.  This will include any shortcuts and properties that are defined for the class.  This will also include any commands that are inherited from other classes.  Lets look at the code that makes this possible:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>95
96
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">      member_filter = <span style="color: #ff7700;font-weight:bold;">lambda</span> obj: <span style="color: #dc143c;">inspect</span>.<span style="color: black;">ismethod</span><span style="color: black;">&#40;</span>obj<span style="color: black;">&#41;</span> <span style="color: #ff7700;font-weight:bold;">or</span> <span style="color: #008000;">isinstance</span><span style="color: black;">&#40;</span>obj,<span style="color: #008000;">property</span><span style="color: black;">&#41;</span>
      members = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">inspect</span>.<span style="color: black;">getmembers</span><span style="color: black;">&#40;</span>obj, member_filter<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>.<span style="color: black;">keys</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>First we create a quick little lambda function that returns True or false.  We want to get a list of all methods and properties of our class, so the lambda function will return True only if the &#8220;obj&#8221; argument is a method or property.  Next, we execute the <em>inspect.getmembers</em> function and pass in the obj (which is our solver class at this moment) and our lambda function from above.  In python, the <em>inspect.getmembers</em> function would return the following:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt;&gt;&gt; import inspect
&gt;&gt;&gt; from patristocrat import PatristocratSolver
&gt;&gt;&gt; member_filter = lambda obj: inspect.ismethod(obj) or isinstance(obj,property)
&gt;&gt;&gt; inspect.getmembers(PatristocratSolver,member_filter)
[('__init__', &lt;unbound method PatristocratSolver.__init__&gt;),
('_display_help', &lt;unbound method PatristocratSolver._display_help&gt;),
('_inherit_docs', &lt;unbound method PatristocratSolver._inherit_docs&gt;),
('_print_counts', &lt;unbound method PatristocratSolver._print_counts&gt;),
('display', &lt;unbound method PatristocratSolver.display&gt;),
('frequency_list', &lt;unbound method PatristocratSolver.frequency_list&gt;),
('keys', &lt;unbound method PatristocratSolver.keys&gt;),
('set', &lt;unbound method PatristocratSolver.set&gt;),
('solve', &lt;unbound method PatristocratSolver.solve&gt;),
('text', &lt;property object at 0xb7c556bc&gt;)]
&gt;&gt;&gt;</pre></div></div>

<p>It returns a big list of name/value pairs for all the members that the member_filter evaluated to True.  It would be a much longer list if we had not passed in a filter function.  The documentation system will use this list to display a nicely formatted display of commands that we can execute.</p>
<h6>Methods</h6>
<p>When a method name is passed into the function, the doc string for the function is displayed, followed by the appropriate way to call the function and what parameters to pass in.  Doc strings are an important part of Python classes and functions.  They help provide documentation automatically.  Doc strings are placed on the line directly below the declaration of the method.  They are started with three quotes &#8220;&#8221;" and ended with three more quotes &#8220;&#8221;" Lets add a doc string to the display method and then see how our documentation system will react to it.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>41
42
43
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> display<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Displays the current data on the screen.&quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">text</span></pre></td></tr></table></div>

<p>Here we have add just one line right below the declaration of the display method.  The doc string can contain any information you want displayed.  It can really be as long as you want and can span multiple lines.  Now lets see how it works.  Load up the solver  and select Patristocrat.</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">Loaded Patristocrat Solver.
&gt; display?
&nbsp;
display [d]:
&nbsp;
   Displays the current data on the screen.
&nbsp;
   Usage:
      display
&nbsp;
&gt;</pre></div></div>

<p>Thee display isn&#8217;t as impressive as if we looked at the frequency_list function. Lets check that one out to better see what is displayed (Note: We haven&#8217;t put in a doc string for the frequency_list function yet so you won&#8217;t see that):</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt; frequency_list?
&nbsp;
frequency_list [f]:
&nbsp;
   Usage:
      frequency_list length=1 text=''
&nbsp;
&gt;</pre></div></div>

<p>We can see the names and default values for the frequency_list.  If we don&#8217;t pass in anything (by just typing frequency_list and hitting enter), it will automatically pass in a length of 1 and use the internal text value.  But we could pass in other lengths if we want to.  You don&#8217;t have to do anything special to get this to display nicely like this.  The code for it is actually quite simple thanks to the <em>inspect</em> module.  The inspect code is in the <em>_get_function_def</em> method that we declared above.  </p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>113
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">      output += <span style="color: #483d8b;">&quot;   Usage:<span style="color: #000099; font-weight: bold;">\n</span>      &quot;</span> + _get_function_def<span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span>, obj<span style="color: black;">&#41;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>64
65
66
67
68
69
70
71
72
73
74
75
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">    <span style="color: #ff7700;font-weight:bold;">def</span> _get_function_def<span style="color: black;">&#40;</span>name,function<span style="color: black;">&#41;</span>:
      specs = <span style="color: #dc143c;">inspect</span>.<span style="color: black;">getargspec</span><span style="color: black;">&#40;</span>function<span style="color: black;">&#41;</span>
      defaults = <span style="color: #008000;">None</span>
      <span style="color: #ff7700;font-weight:bold;">if</span> specs.<span style="color: black;">defaults</span>:
        defaults = <span style="color: #008000;">dict</span><span style="color: black;">&#40;</span><span style="color: #008000;">zip</span><span style="color: black;">&#40;</span>specs.<span style="color: black;">args</span><span style="color: black;">&#91;</span>-<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>specs.<span style="color: black;">defaults</span><span style="color: black;">&#41;</span>:<span style="color: black;">&#93;</span>,specs.<span style="color: black;">defaults</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
      output = name
      <span style="color: #ff7700;font-weight:bold;">for</span> arg <span style="color: #ff7700;font-weight:bold;">in</span> specs.<span style="color: black;">args</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> arg <span style="color: #66cc66;">!</span>= <span style="color: #483d8b;">'self'</span>:
          output += <span style="color: #483d8b;">&quot; &quot;</span> + arg
          <span style="color: #ff7700;font-weight:bold;">if</span> defaults <span style="color: #ff7700;font-weight:bold;">and</span> arg <span style="color: #ff7700;font-weight:bold;">in</span> defaults:
            output += <span style="color: #483d8b;">&quot;=&quot;</span> + <span style="color: #dc143c;">repr</span><span style="color: black;">&#40;</span>defaults<span style="color: black;">&#91;</span>arg<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
      <span style="color: #ff7700;font-weight:bold;">return</span> output</pre></td></tr></table></div>

<p>The <em>inspect.getargspec</em> function takes a function as the argument and returns all the information about the function:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt;&gt;&gt; specs = inspect.getargspec(PatristocratSolver.frequency_list)
&gt;&gt;&gt; specs
ArgSpec(args=['self', 'length', 'text'], varargs=None, keywords=None, defaults=(1, ''))
&gt;&gt;&gt;</pre></div></div>

<p>The returned value is called a named tuple.  It has all the little chunks of information that we can use.  One of the cool things we can do is use the <em>zip</em> function to attach the argument names back to their default values:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt;&gt;&gt; defaults = dict(zip(specs.args[-len(specs.defaults):],specs.defaults))
&gt;&gt;&gt; defaults
{'text': '', 'length': 1}
&gt;&gt;&gt;</pre></div></div>

<p>The rest of the code is just the fluffy display code that makes everything look nice.</p>
<h6>Properties</h6>
<p>Properties are a great way to get and set different values that our solver will use.  We want to be able to get and set the <em>Cipher.text</em> from within our solver class.  Lets declare our new property in <em>CipherSolver</em>:</p>
<p class="wp-caption">Contents of cipher.py (Add to the CipherSolver class)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>45
46
47
48
49
50
51
52
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  @<span style="color: #008000;">property</span>
  <span style="color: #ff7700;font-weight:bold;">def</span> text<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;The raw text value used for encoding and decoding.&quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">text</span>
&nbsp;
  @text.<span style="color: black;">setter</span>
  <span style="color: #ff7700;font-weight:bold;">def</span> text<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>,value<span style="color: black;">&#41;</span>:
    <span style="color: #008000;">self</span>.<span style="color: black;">cipher</span>.<span style="color: black;">text</span> = value</pre></td></tr></table></div>

<p>The &#8220;@property&#8221; tells python that we want the method that follows it to be a property.  So now whenever we use the &#8220;text&#8221; command, the cipher.text will be display.  The &#8220;@text.setter&#8221; tells python that if we try to set the text property, it should change the  cipher.text.  We can create as many of these kinds of properties we want whenever we want to get and set special values.  We&#8217;ll probably use them a lot when working with out cipher types.</p>
<p>The display for properties is different from the classes and methods from above.  Lets see what our new text property looks like in the documentation system and the solver.  Lets load up sandbox.py:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt; text?
&nbsp;
text:
&nbsp;
   The raw text value used for encoding and decoding.
&nbsp;
   To display the value:
      text
&nbsp;
   To change the value:
      text value
&nbsp;
&gt;</pre></div></div>

<p>So it shows the doc string for the property, how to display it, and also had to change it.  Lets display and set our property:</p>

<div class="wp_syntax"><div class="code"><pre class="terminal" style="font-family:monospace;">&gt; text
&nbsp;
GSRHRHZGVH GLUGSVVNVITVMXBYIL ZWXZHGHBHGVN
&nbsp;
&gt; text &quot;THIS IS A TEST&quot;
&nbsp;
&nbsp;
&gt; text
&nbsp;
THIS IS A TEST
&nbsp;
&gt;</pre></div></div>

<p>Now we can easily set the text property whenever we want to start a new con.  These properties are really easy to create and are very powerful.  Python makes it very easy to enhance our solver with whatever we need to get the job done.</p>
<h4>Document Everything!</h4>
<p>At this point the implementation of the documentation system is complete.  All we have to do now is just add doc strings to all our methods and properties in each of the solver classes.</p>
<h6>CipherSolver (cipher.py)</h6>
<p>We&#8217;ve already added the doc strings to the existing methods and properties in our CipherSolver but lets add one more method that will come in handy.  The <em>clear</em> method just clears the screen whenever called.  Sometimes when you&#8217;d made a lot of changes and there is tons of data on the screen, it is refreshing just to clear the screen before you continue.  Add the following code above the display method:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>37
38
39
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> clear<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Clears the screen&quot;&quot;&quot;</span>
    shared.<span style="color: black;">clear_screen</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<h6>AristocratSolver (aristocrat.py)</h6>
<p>Since the <em>AristocratSolver</em> class inherits from <em>CipherSolver</em>, we want to make sure that all our overridden methods like display get their doc strings set correctly so we don&#8217;t have to repeat ourselves.  We do this by just adding a call to the <em>_inherit_docs</em> method in the <em>AristocratSolver.__init__</em></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>41
42
43
44
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> AristocratSolver<span style="color: black;">&#40;</span>CipherSolver<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    CipherSolver.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>._inherit_docs<span style="color: black;">&#40;</span>CipherSolver<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>We need to add a few bits of documentation to our existing methods inside the <em>AristocratSolver</em> class.  Add the following doc strings:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>60
61
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> frequency_list<span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, length = <span style="color: #ff4500;">1</span>, text = <span style="color: #483d8b;">&quot;&quot;</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Displays counts for frequencies of characters&quot;&quot;&quot;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>65
66
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> keys<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Displays the plaintext and ciphertext keys.&quot;&quot;&quot;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>77
78
79
80
</pre></td><td class="code"><pre class="python" style="font-family:monospace;">  <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #008000;">set</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, ct, pt = <span style="color: #483d8b;">&quot;-&quot;</span><span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Sets the plaintext equivalent for each ciphertext character.
    You can enter multiple letters at a time.
    Enter a single dash '-' to set the plaintext characters to blank.&quot;&quot;&quot;</span></pre></td></tr></table></div>

<h6>PatristocratSolver (patristocrat.py)</h6>
<p><em>PatristocratSolver</em> class inherits from <em>AristocratSolver</em> so we need to call the <em>_inherit_docs</em> method in the <em>PatristocratSolver.__init__:</em></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>12
13
14
15
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">class</span> PatristocratSolver<span style="color: black;">&#40;</span>AristocratSolver<span style="color: black;">&#41;</span>:
  <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
    AristocratSolver.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
    <span style="color: #008000;">self</span>._inherit_docs<span style="color: black;">&#40;</span>AristocratSolver<span style="color: black;">&#41;</span></pre></td></tr></table></div>

<h4>Conclusion</h4>
<p>That was a lot!  Hopefully, you survived up to this point.  This concludes the documentation system for the interactive solver.  You can add your own methods to any of the classes and add doc strings to document things.  In Part V, the next and last article in this series, we will include loading the cons from the Cryptogram Digital Con files (available at cryptogram.org for members).</p>
<h4>Complete Source Code</h4>
<p>You can download the complete source code to Part IV at: <a href='http://www.codepenguin.com/2009/10/31/creating-an-interactive-cryptogram-solver-part-iv/solver_part_4/' rel='attachment wp-att-370'>Creating an interactive cryptogram solver (Part IV – Source)</a>.</p>
<h4>Related Posts:</h4>
<p>
<a href="/2009/09/17/creating-an-interactive-cryptogram-solver-introduction/">Creating an interactive cryptogram solver (Introduction)</a><br />
<a href="/2009/09/19/creating-an-interactive-cryptogram-solver-part-i/">Creating an interactive cryptogram solver (Part I)</a><br />
<a href="/2009/09/20/creating-an-interactive-cryptogram-solver-part-ii/">Creating an interactive cryptogram solver (Part II)</a><br />
<a href="/2009/09/22/creating-an-interactive-cryptogram-solver-part-iii/">Creating an interactive cryptogram solver (Part III)</a></p>
<img src="http://feeds.feedburner.com/~r/codepenguin/SpFe/~4/qFmMBbSDTV4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.codepenguin.com/2009/10/31/creating-an-interactive-cryptogram-solver-part-iv/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.codepenguin.com/2009/10/31/creating-an-interactive-cryptogram-solver-part-iv/</feedburner:origLink></item>
	</channel>
</rss>

