<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Blogging to Nowhere &#187; python</title>
	<atom:link href="http://webworxshop.com/tag/python/feed" rel="self" type="application/rss+xml" />
	<link>http://webworxshop.com</link>
	<description>cat /dev/brain &#62; /dev/null</description>
	<lastBuildDate>Wed, 04 Jan 2012 02:45:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" />
	<atom:link rel="hub" href="http://superfeedr.com/hubbub" />
			<item>
		<title>Unofficial Python Module of the Week #2: configobj</title>
		<link>http://webworxshop.com/2011/02/07/unofficial-python-module-of-the-week-2-configobj</link>
		<comments>http://webworxshop.com/2011/02/07/unofficial-python-module-of-the-week-2-configobj#comments</comments>
		<pubDate>Mon, 07 Feb 2011 02:23:07 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[configobj]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[upmotw]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=522</guid>
		<description><![CDATA[Welcome to our third instalment of interesting Python modules. Unfortunately I'm a bit late with this section this week - in fact its next week already! The fourth instalment should be along towards the end of the week thus catching me up.

Today we're going to cover something which isn't in the standard library, but ...]]></description>
			<content:encoded><![CDATA[<p>Welcome to our third instalment of interesting Python modules. Unfortunately I&#8217;m a bit late with this section this week &#8211; in fact its <em>next</em> week already! The fourth instalment should be along towards the end of the week thus catching me up.</p>
<p>Today we&#8217;re going to cover something which isn&#8217;t in the standard library, but is nonetheless very useful. The module is <a href="http://www.voidspace.org.uk/python/configobj.html">configobj</a> which is used for reading from and writing to INI style configuration files files. A simple INI file is shown below:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">item1</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> value</span>
<span style="color: #000099;">item2</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> value2</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span> section1 <span style="">&#93;</span></span>
<span style="color: #000099;">item1</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> value</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span><span style="">&#91;</span> subsection <span style="">&#93;</span><span style="">&#93;</span></span>
<span style="color: #000099;">item1</span> <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> value</span></pre></div></div>

<p>In the above we can see the simple use of items, values sections and subsection. Subsections can be nested down as far a you want, but I don&#8217;t think most applications will need many more than two or three levels.</p>
<p><strong>Installation</strong></p>
<p>As this module isn&#8217;t in the standard library, we need to install it. On most Linux distros it should be in the package repositories, for example on Fedora 14:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #c20cb9; font-weight: bold;">install</span> python-configobj</pre></div></div>

<p>Windows and Mac users can install from PyPi by following the <a href="http://www.voidspace.org.uk/python/configobj.html#installing">instructions</a> on the homepage.</p>
<p><strong>Basic Usage</strong></p>
<p>Reading from a configuration file with configobj couldn&#8217;t really be any simpler:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> configobj
config = configob.<span style="color: black;">ConfigObj</span><span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>
myoption = config<span style="color: black;">&#91;</span><span style="color: #483d8b;">'item1'</span><span style="color: black;">&#93;</span>
mysectionoption = config<span style="color: black;">&#91;</span><span style="color: #483d8b;">'section1'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'item1'</span><span style="color: black;">&#93;</span>
mysubsectionoption = config<span style="color: black;">&#91;</span><span style="color: #483d8b;">'section1'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'subsection'</span><span style="color: black;">&#93;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">'item1'</span><span style="color: black;">&#93;</span></pre></div></div>

<p>Basically, all you need to do is open a ConfigObj object by passing it a filename, then you just read from it as if its a dictionary object. Sections and subsections appear as nested dictionaries. Writing to the file is just as simple:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> configobj
config = configob.<span style="color: black;">ConfigObj</span><span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>
config<span style="color: black;">&#91;</span><span style="color: #483d8b;">'newoption'</span><span style="color: black;">&#93;</span> = <span style="color: #483d8b;">'new stuff'</span>
config.<span style="color: black;">write</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>No surprises here, you just write to it as if it were a dictionary. All you have to do it call the write() method when you&#8217;ve finished, in order to sync everything to disk.</p>
<p>That&#8217;s pretty much it for basic usage. There is much more you can do with configobj, including advanced stuff like validation of configuration files. Check out the <a href="http://www.voidspace.org.uk/python/configobj.html">documentation</a> for more info.</p>
<p class="wp-flattr-button"></p> <p><a href="http://webworxshop.com/?flattrss_redirect&amp;id=522&amp;md5=446f568352a6df7a758ed067502cfe4b" title="Flattr" target="_blank"><img src="http://webworxshop.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2011/02/07/unofficial-python-module-of-the-week-2-configobj/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unofficial Python Module of the Week #1: shelve</title>
		<link>http://webworxshop.com/2011/01/28/unofficial-python-module-of-the-week-1-shelve</link>
		<comments>http://webworxshop.com/2011/01/28/unofficial-python-module-of-the-week-1-shelve#comments</comments>
		<pubDate>Thu, 27 Jan 2011 21:06:17 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[shelve]]></category>
		<category><![CDATA[upmotw]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=494</guid>
		<description><![CDATA[Here we are, the second Unofficial Python Module of the Week. Yes, the second - we started from zero (obviously!). This week we are covering the shelve module. Shelve provides you with a very simple Python object store. You can use it where you need quick persistent storage of objects between program runs, it's ...]]></description>
			<content:encoded><![CDATA[<p>Here we are, the second Unofficial Python Module of the Week. Yes, the second &#8211; we started from zero (obviously!). This week we are covering the shelve module. Shelve provides you with a very simple Python object store. You can use it where you need quick persistent storage of objects between program runs, it&#8217;s much less overhead than using a database &#8211; even SQLite. Anyway, lets dive straight into it:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">shelve</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> shelf = <span style="color: #dc143c;">shelve</span>.<span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;myshelf.db&quot;</span>, writeback=<span style="color: #008000;">True</span><span style="color: black;">&#41;</span></pre></div></div>

<p>Here we import the shelve module (its in the standard library, so there&#8217;s no installation required). Then we open our persistent object store, supplying the filename that we want to store the objects in and the writeback parameter, which allows mutable objects to be stored more conveniently (otherwise they are only written when an assignment is performed). The writeback parameter also causes data to be cached in memory, which can be quite memory intensive, so you should call shelf.sync() every so on to flush everything to disk.</p>
<p>You can store anything that can be handled by the Python pickle module in a shelf:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> shelf<span style="color: black;">&#91;</span><span style="color: #483d8b;">'thedict'</span><span style="color: black;">&#93;</span> = <span style="color: black;">&#123;</span><span style="color: #483d8b;">'one'</span>: <span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'two'</span>: <span style="color: #ff4500;">2</span>, <span style="color: #483d8b;">'three'</span>: <span style="color: #ff4500;">3</span><span style="color: black;">&#125;</span>
<span style="color: #66cc66;">&gt;&gt;&gt;</span> shelf.<span style="color: black;">sync</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>As you can see, using a shelf is just like using a dictionary. The only real limit is that the keys must be strings. You can also read back values from the shelf as with a dictionary:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> <span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span>shelf<span style="color: black;">&#91;</span><span style="color: #483d8b;">'thedict'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#123;</span><span style="color: #483d8b;">'one'</span>: <span style="color: #ff4500;">1</span>, <span style="color: #483d8b;">'two'</span>: <span style="color: #ff4500;">2</span>, <span style="color: #483d8b;">'three'</span>: <span style="color: #ff4500;">3</span><span style="color: black;">&#125;</span></pre></div></div>

<p>That&#8217;s just about it, just remember to close the shelf when you&#8217;re finished with it:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #66cc66;">&gt;&gt;&gt;</span> shelf.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>If you want to find out more have a look at the official <a href="http://docs.python.org/library/shelve.html">Python docs for shelve</a> and <a href="http://www.doughellmann.com/PyMOTW/shelve/index.html">Doug Hellmann&#8217;s PyMOTW posting on the subject</a>.</p>
<p class="wp-flattr-button"></p> <p><a href="http://webworxshop.com/?flattrss_redirect&amp;id=494&amp;md5=e18e4bf391c877fa1f5cd8df20ff844f" title="Flattr" target="_blank"><img src="http://webworxshop.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2011/01/28/unofficial-python-module-of-the-week-1-shelve/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Review: Piwik Analytics Software</title>
		<link>http://webworxshop.com/2011/01/21/review-piwik-analytics-software</link>
		<comments>http://webworxshop.com/2011/01/21/review-piwik-analytics-software#comments</comments>
		<pubDate>Thu, 20 Jan 2011 20:37:53 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Reviews]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[google analytics]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[piwik]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=403</guid>
		<description><![CDATA[If you read my previous post regarding the site overhaul that I'm currently doing you will have seen me mention that I'm now using the Piwik Open Source Analytics Package in place of Google Analytics. Well I've had it running for a few days and have played around with it a bit, so I ...]]></description>
			<content:encoded><![CDATA[<p>If you read my previous post regarding the <a href="http://blog.webworxshop.com/2011/01/13/giving-this-site-an-overhaul">site overhaul</a> that I&#8217;m currently doing you will have seen me mention that I&#8217;m now using the <a href="http://piwik.org">Piwik</a> Open Source Analytics Package in place of <a href="http://analytics.google.com">Google Analytics</a>. Well I&#8217;ve had it running for a few days and have played around with it a bit, so I thought I&#8217;d review it. I&#8217;m going to start with my reasons for moving from GA and then move along and score it on several different criteria:</p>
<ul>
<li>Installation and Setup</li>
<li>Site integration</li>
<li>User interface</li>
<li>Extensibility (API availability)</li>
<li>Overall impressions (documentation, community, etc.)</li>
</ul>
<p><strong>The philosophical argument</strong></p>
<p>As well as the obvious benefit (from a Freedom perspective) of using one less proprietary web service, there is also another reason that I switched away from Google Analytics. Basically, this was privacy. For a while I&#8217;ve been using technologies to limit the amount of data which leaks from my browser as I navigate the web, in order to reduce the amount of profiling of my web activities. This isn&#8217;t because I have anything to hide. I just don&#8217;t like the idea of large companies building up a huge database on me, without my permission. The upshot of this is that I found myself in the slightly hypocritical situation of blocking GA in my own browser, but using it to track others on my site.</p>
<p>The solution was obvious, remove GA from my site. However, I didn&#8217;t want to lose the valuable information that it provides me with. Also, I don&#8217;t have a problem with site owners collecting data that can help them, just with them sharing it with 3rd parties such as Google, who then build it into their larger profiling efforts. A quick search turned up <a href="http://piwik.org">Piwik</a> which aims to provide a full featured GA replacement that you can run on your own server. Because site owners run their own instances, they remain in charge of their tracking of users, retain ownership of the data and best of all don&#8217;t give any data to Google.</p>
<p>With the aim of responsible and unobtrusive tracking in mind I&#8217;ve added a page to my site to allow users to <a href="http://blog.webworxshop.com/tracking-opt-out">Opt-out</a> of the Piwik tracking by means of a cookie. The link is also accessible from the sidebar under the copyright notice. I&#8217;m afraid some of the text on that page is pretty difficult to see with my current theme, but I&#8217;m working on this. For now just uncheck the check box to opt-out.</p>
<p>Right, on to the main event, the actual review&#8230;</p>
<p><strong>1. Installation and Setup</strong></p>
<p>There&#8217;s actually not much to say here, which is because installation was ridiculously easy! I just downloaded the zip to my sever (with wget) and unzipped it into my server root directory. This produced a directory called &#8216;piwik&#8217; and a &#8216;How to Install Piwik.html&#8217; file, which if you point your browser at it will redirect you to the <a href="http://piwik.org/docs/installation/">installation instructions</a>. The rest of the installation was fairly simple, following the instructions I pointed my browser at the &#8216;/piwik/&#8217; directory of my site and was greeted by the installer. Following this was really easy, you&#8217;ll need to create a MySQL database when prompted for the database info, but that&#8217;s about as hard as it gets. Towards the end you&#8217;ll be prompted to setup your site with Piwik which involves entering a few details about the site, then you&#8217;ll be provided with a snippet of JavaScript to add to your site template. Which leads me neatly into the next section&#8230;</p>
<p><strong>2. Site Integration</strong></p>
<p>I didn&#8217;t copy and paste the JavaScript into my template, instead opting to install the WP-Piwik addon for WordPress. This made the set up easy and also gave me a widget on my WordPress admin dashboard which gives me a nice overview of my site visits. As I already said I was also able to add a widget to the site to enable visitors to opt-out of tracking. This was also simple, just involving a copy and paste of a couple of lines of HTML from one of the settings pages into a WordPress page. Easy!</p>
<p>You can also integrate Piwik widgets with your site, by following the <a href="http://piwik.org/docs/embed-piwik-report/">instructions in the documentation</a>, this is a neat feature, especially if you have a custom start page set in your web browser (something which I have yet to get around to making).</p>
<p>I also investigated the campaigns functionality in order to track entries to my site from the RSS feed. This is really simple to use, all you have to do is append the query string &#8216;?piwik_campaign=NAME&#8217;, where NAME is the name of your campaign to the end of a URL, to have it show up under that campaign. I found that I could integrate this with WordPress pretty well by adding the following snippet of code to the functions.php file of my theme:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> piwik_track_feed<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
     <span style="color: #000088;">$url</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;?piwik_campaign=RSS&quot;</span><span style="color: #339933;">;</span>
     <span style="color: #b1b100;">return</span> <span style="color: #000088;">$url</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;the_permalink_rss&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;piwik_track_feed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>If you now check the URLs in your RSS feeds, they will all have the query string added and clicks will be attributed to the &#8216;RSS&#8217; campaign in Piwik.</p>
<p><strong>3. User Interface</strong></p>
<p>The Piwik user interface is really nice. I&#8217;ve included some screenshots below, so that you can make up your own mind. It&#8217;s pretty similar to the GA user interface, only cleaner and all the AJAX stuff makes it feel really responsive. I also love the real time tracking widget, which is something GA totally lacks. The only bad thing about the UI is the requirement of Flash for the graphs. I hate Flash and it doesn&#8217;t have a reliable 64-bit Linux version, which means I only have it installed on my netbook. Oh, and before you ask, I tried it with <a href="http://gnashdev.org/">Gnash</a> and it didn&#8217;t work!</p>

<a href='http://webworxshop.com/2011/01/21/review-piwik-analytics-software/piwik_screenshot_2' title='Piwik Locations Page'><img width="150" height="150" src="http://blog.webworxshop.com/wp-content/uploads/2011/01/piwik_screenshot_2-150x150.png" class="attachment-thumbnail" alt="Piwik Locations Page" title="Piwik Locations Page" /></a>
<a href='http://webworxshop.com/2011/01/21/review-piwik-analytics-software/piwik_screenshot_3' title='Piwik Search Engine Pages'><img width="150" height="150" src="http://blog.webworxshop.com/wp-content/uploads/2011/01/piwik_screenshot_3-150x150.png" class="attachment-thumbnail" alt="Piwik Search Engine Pages" title="Piwik Search Engine Pages" /></a>
<a href='http://webworxshop.com/2011/01/21/review-piwik-analytics-software/piwik_screenshot_1' title='Main Piwik Dashboard'><img width="150" height="150" src="http://blog.webworxshop.com/wp-content/uploads/2011/01/piwik_screenshot_1-150x150.png" class="attachment-thumbnail" alt="Main Piwik Dashboard" title="Main Piwik Dashboard" /></a>

<p><strong>4. Extensibility</strong></p>
<p>By extensibility, I was primarily interested in API access. There&#8217;s certainly no shortage of this with two APIs listed on the <a href="http://piwik.org/docs/">documentation page</a>. One API is for performing tracking, which I didn&#8217;t need given my usage of the WordPress plugin. I looked instead at the <a href="http://piwik.org/docs/analytics-api/">analytics API</a>, which allows you to access all the data through simple HTTP requests. I was able to write a simple Python script to email me my main statistics once a day, in about an hour (including working out how the Python email and smtplib modules work!). Performing an Piwik API call in Python is as simple as:</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;">def</span> getVisits<span style="color: black;">&#40;</span>idSite, period, date<span style="color: black;">&#41;</span>:
    url = <span style="color: #483d8b;">&quot;%s/index.php?module=API&amp;method=VisitsSummary.get&amp;idSite=%d&amp;perio$
    return json.load(urllib2.urlopen(url))</span></pre></td></tr></table></div>

<p>Of course, as it&#8217;s Python its ridiculously simple!</p>
<p>Of course, if you find something that you can&#8217;t do with the API (which is unlikely, because it seems to cover everything), the you can access the data in the database &#8211; because it&#8217;s in YOUR database. You can also back-up and secure your data exactly how you want to. This is something that GA just can&#8217;t compete with!</p>
<p><strong>5. Overall Impressions</strong></p>
<p>My impressions of Piwik as a project have been really good. The documentation is excellent and there seems to be a good community behind it. As a product its a pleasure to use, really easy to install and just works. The reliance on flash for the graphs is a bit disappointing, but perhaps this will change in the future as HTML5 matures. Here are the obligatory scores:</p>
<ul>
<li>Installation and Setup &#8211; 5/5</li>
<li>Site Integration &#8211; 4/5</li>
<li>User Interface &#8211; 3/5</li>
<li>Extensibility &#8211; 5/5</li>
</ul>
<p><strong>Overall Score: 4/5</strong></p>
<p><strong>Verdict: If your currently using Google Analytics, stop it! (and use this instead)<br />
</strong></p>
<p class="wp-flattr-button"></p> <p><a href="http://webworxshop.com/?flattrss_redirect&amp;id=403&amp;md5=e6f4ae5a275cf188ea6e2d671020c5bc" title="Flattr" target="_blank"><img src="http://webworxshop.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2011/01/21/review-piwik-analytics-software/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Unofficial Python Module of the Week #0: argparse</title>
		<link>http://webworxshop.com/2011/01/20/python-module-of-the-week-0-argparse</link>
		<comments>http://webworxshop.com/2011/01/20/python-module-of-the-week-0-argparse#comments</comments>
		<pubDate>Wed, 19 Jan 2011 19:00:19 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[argparse]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[upmotw]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=437</guid>
		<description><![CDATA[

I'm going to try something different today. This is going to be the first in a series (hopefully once weekly) of Python Modules of the Week. This has probably ...]]></description>
			<content:encoded><![CDATA[<p><em>[EDIT: This series has been renamed so as not to conflict with Doug Hellman's excellent Python Module of the Week series. See UPMotW #1 for details]</em></p>
<p><em>I&#8217;m going to try something different today. This is going to be the first in a series (hopefully once weekly) of Python Modules of the Week. This has probably been done to death elsewhere, but I&#8217;m using it as an opportunity to learn some</em> <em>more Python</em> <em>and to cement some of these modules in my mind.</em></p>
<p><a href="http://docs.python.org/library/argparse.html">Argparse</a> is a Python module for processing command line arguments. It&#8217;s new in version 2.7 and is designed to replace the <a href="http://docs.python.org/library/optparse.html">Optparse</a> module. I&#8217;m not sure what the rationale for the change was as the two modules look very similar to me. However, it suffices to say that you should use argparse in all new code.</p>
<p>The main class of argparse is called ArgumentParser, it allows you to add arguments to your program and parse the provided arguments at runtime:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">parser</span> = argparse.<span style="color: black;">ArgumentParser</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_argument</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;-v&quot;</span>, <span style="color: #483d8b;">&quot;--verbose&quot;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># a flag type argument</span>
<span style="color: #dc143c;">parser</span>.<span style="color: black;">add_argument</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;value&quot;</span>, <span style="color: #008000;">type</span>=<span style="color: #008000;">int</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># an integer positional argument</span>
...
<span style="color: black;">args</span> = <span style="color: #dc143c;">parser</span>.<span style="color: black;">parse_args</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># parse the args from sys.argv</span>
<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span>args.<span style="color: black;">value</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># arguments accessed as data members</span></pre></td></tr></table></div>

<p>You can also add meta-data such as help and descriptions to your arguments via keyword arguments to many of the methods. Take a look at the <a href="http://docs.python.org/library/argparse.html">module documentation</a> for examples. Once nice thing is that when you provide this data, argparse automatically generates the -h and &#8211;help flags and populates them with nicely formatted help output using the info you provide.</p>
<p>The argument parsing provided by argparse allows you to create some very complex command line interfaces to your scripts. I especially like the <a href="http://docs.python.org/library/argparse.html#sub-commands">sub-commands</a> framework, which allows each sub-command to exist as its own separate entity with its own options and help information. To create an argument parser with a sub-command is just a few lines:</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: #dc143c;">parser</span> = argparse.<span style="color: black;">ArgumentParser</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
subcommands = <span style="color: #dc143c;">parser</span>.<span style="color: black;">add_subparsers</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
mysubcommand = subcommands.<span style="color: black;">add_parser</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">'mysubcommand'</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

<p>Of course,each sub-command is an ArgumentParser in its own right, so you can add all the options that you normally would, including command line flags, positional arguments and help information. Also each sub-command will be listed in the help and will also have its own help page which can be accessed via:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">.<span style="color: #000000; font-weight: bold;">/</span>pyprog.py subcommand <span style="color: #660033;">--help</span></pre></td></tr></table></div>

<p>All in all, this is a very useful Python module to know about. Its ease of use and the number of things it &#8216;just takes care of&#8217; make it a pleasure to use. Hopefully it&#8217;ll have you writing nice command line interfaces to all those hacked together scripts that are currently controlled by commenting bits of them in and out!</p>
<p class="wp-flattr-button"></p> <p><a href="http://webworxshop.com/?flattrss_redirect&amp;id=437&amp;md5=91c03113256d93a0dc851c4079a5dbb4" title="Flattr" target="_blank"><img src="http://webworxshop.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2011/01/20/python-module-of-the-week-0-argparse/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automating routine tasks&#8230;</title>
		<link>http://webworxshop.com/2011/01/19/automating-routine-tasks</link>
		<comments>http://webworxshop.com/2011/01/19/automating-routine-tasks#comments</comments>
		<pubDate>Tue, 18 Jan 2011 20:50:59 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[automation]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[rss2email]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=449</guid>
		<description><![CDATA[I've been thinking more recently about automating routine computing tasks. Using Free Software this is ridiculously easy, usually a combination of Python and Cron does the trick. More difficult I have found is actually working out what to automate. It's very easy to get into the habit of doing something and then not realise ...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been thinking more recently about automating routine computing tasks. Using Free Software this is ridiculously easy, usually a combination of Python and Cron does the trick. More difficult I have found is actually working out what to automate. It&#8217;s very easy to get into the habit of doing something and then not realise that you do it every day, or every hour when in front of the computer.</p>
<p>One of my major successes in this area has been in terms of feed reading. A while ago I setup <a href="http://www.allthingsrss.com/rss2email/">rss2email</a> on my server to check my feeds and email the stories to me. Previous to this I actually found it really hard to ever get around to reading news feeds. I think this was mainly because checking news feeds suffers from the &#8216;extra inbox problem&#8217;, its just more stuff to check. Having news stories emailed to me fixes this and I can also read them easily on my phone. Because I use IMAP email, my read/unread status is also synchronised on all my computers.</p>
<p>Now I&#8217;m kind of at a brick wall. I don&#8217;t know what else I can set up to reduce the number of routine tasks I do. The purpose of this post is to crowd source that problem. I want everyone reading this to get back to me with the things they&#8217;ve set up to help them. You can get in touch either through the comments on this post, or via <a href="http://identi.ca/robconnolly">identi.ca</a>. If I get enough responses I&#8217;ll write a follow up post detailing some of the best ideas.</p>
<p class="wp-flattr-button"></p> <p><a href="http://webworxshop.com/?flattrss_redirect&amp;id=449&amp;md5=43b5c5738e86fa3ffb6b6a21377687ca" title="Flattr" target="_blank"><img src="http://webworxshop.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2011/01/19/automating-routine-tasks/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>The Long Awaited Kiwi Pycon Round-Up</title>
		<link>http://webworxshop.com/2011/01/17/the-long-awaited-kiwi-pycon-round-up</link>
		<comments>http://webworxshop.com/2011/01/17/the-long-awaited-kiwi-pycon-round-up#comments</comments>
		<pubDate>Sun, 16 Jan 2011 23:03:03 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[kiwi pycon]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[videos]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=406</guid>
		<description><![CDATA[OK, so this isn't going to be as large a round up as I envisaged. Principally because its been so long since the actual event and also because only one talk video is currently available - I guess all that video editing is a big job! Also, I haven't really had the time to ...]]></description>
			<content:encoded><![CDATA[<p>OK, so this isn&#8217;t going to be as large a round up as I envisaged. Principally because its been so long since the actual event and also because only one talk video is currently available &#8211; I guess all that video editing is a big job! Also, I haven&#8217;t really had the time to investigate much of the stuff I learned about over that weekend as my current Python programming is limited to the odd script here and there (most of my programming is sadly limited to C++ and Java for reasons out of my control).</p>
<p>Anyway, it just so happens that the video that is up is from probably the best talk of the weekend, Anthony Baxter&#8217;s &#8216;Pythonic APIs&#8217;. This talk made me laugh from start to finish and taught me some things I didn&#8217;t know, watch the video below if you&#8217;re interested (brought to you by the magic of HTML5!).</p>
<p><video src="http://blip.tv/file/get/Kiwipycon-PythonicAPIsAnthonyBaxter498.m4v" poster="http://a.images.blip.tv/Kiwipycon-PythonicAPIsAnthonyBaxter247-307.jpg" controls><br />
Looks like your browser doesn&#8217;t support HTML5 video! D&#8217;oh!<br />
</video></p>
<p>As far as the other videos go, I&#8217;ve subscribed to the <a href="http://kiwipycon.blip.tv/rss">Kiwi Pycon Blip.tv RSS feed</a> so I&#8217;ll be able to share them as they come along.</p>
<p>All that remains is to talk about my overall impressions of the conference, before they completely fade from memory! Basically I really enjoyed myself, everything was very well organised and the venue was excellent. There seemed to be some rumbling that Waitangi was a bit far away from everywhere and that the conference should have been in a city. For me the location was actually a bonus as it meant I had a good excuse to take the following day off and have a bit of a holiday!</p>
<p>So that&#8217;s about it, thanks to Danny, Guy, Tim and everyone else who organised. I had a great time and I even won a prize. I&#8217;m just sorry this post has taken me so long to get around to writing. Maybe I&#8217;ll be quicker off the mark next year!</p>
<p class="wp-flattr-button"></p> <p><a href="http://webworxshop.com/?flattrss_redirect&amp;id=406&amp;md5=9fdc90e4a4f69d433f82a7e34343a561" title="Flattr" target="_blank"><img src="http://webworxshop.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2011/01/17/the-long-awaited-kiwi-pycon-round-up/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://blip.tv/file/get/Kiwipycon-PythonicAPIsAnthonyBaxter498.m4v" length="0" type="video/mp4" />
		</item>
		<item>
		<title>Calculating Alcohol By Volume in Python on Android</title>
		<link>http://webworxshop.com/2011/01/12/calculating-alcohol-by-volume-in-python-on-android</link>
		<comments>http://webworxshop.com/2011/01/12/calculating-alcohol-by-volume-in-python-on-android#comments</comments>
		<pubDate>Wed, 12 Jan 2011 02:14:22 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Tips]]></category>
		<category><![CDATA[abv]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[homebrew]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[specific gravity]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=359</guid>
		<description><![CDATA[Wow, I just managed to combine three of my favourite things in a single title! Recently, I've been getting further into home brewing, with a book I received as a Christmas present (Home Brewed Beers and Stouts, by C.J.J. Berry). Since I'd never actually measured the Alcohol By Volume (ABV) of my beer I ...]]></description>
			<content:encoded><![CDATA[<p>Wow, I just managed to combine three of my favourite things in a single title! Recently, I&#8217;ve been getting further into home brewing, with a book I received as a Christmas present (<a href="http://thenile.co.nz/books/Roy-Elkins/Home-Brewed-Beers-and-Stouts/9781854861238/">Home Brewed Beers and Stouts, by C.J.J. Berry</a>). Since I&#8217;d never actually measured the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Abv">Alcohol By Volume</a> (ABV) of my beer I decided to write some Python code to automate the process. The simple modules I came up with work from the command line and also on Android phones via <a href="https://code.google.com/p/android-scripting/">SL4A</a>, which makes them very useful when doing quick measurements.</p>
<p>Measuring ABV involves taking <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Abv">Specific Gravity</a> (SG) measurements at the start and end of fermentation, adjusting them for temperature and pushing them into a simple formula. The SG measurements are taken with a <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Hydrometer">Hydrometer</a>, which is supposed to read at 20C (hence the need to adjust for other temperatures).</p>
<p>The temperature adjustment is done via a simple table (which I took from the book). In the script I used <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Linear_interpolation">Linear Interpolation</a>, to adapt it for values which weren&#8217;t available in the table. Initially I used the numpy.interp() function. However, I found that numpy isn&#8217;t present in SL4A and that installing it would be a pain since it is a C module which would need cross compiling for Android.</p>
<p>I therefore wrote my own interp() function, which keeps the same interface:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">def</span> interp<span style="color: black;">&#40;</span>x, xp, fp<span style="color: black;">&#41;</span>:
    i = <span style="color: #ff4500;">0</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> p <span style="color: #ff7700;font-weight:bold;">in</span> xp:
        <span style="color: #ff7700;font-weight:bold;">if</span> p <span style="color: #66cc66;">&gt;</span> x:
            i = xp.<span style="color: black;">index</span><span style="color: black;">&#40;</span>p<span style="color: black;">&#41;</span> - <span style="color: #ff4500;">1</span>
            <span style="color: #ff7700;font-weight:bold;">break</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: black;">&#40;</span><span style="color: black;">&#40;</span>x - xp<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><span style="color: #66cc66;">*</span>fp<span style="color: black;">&#91;</span>i+<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> + <span style="color: black;">&#40;</span>xp<span style="color: black;">&#91;</span>i+<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> - x<span style="color: black;">&#41;</span><span style="color: #66cc66;">*</span>fp<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span> / <span style="color: black;">&#40;</span>xp<span style="color: black;">&#91;</span>i+<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> - xp<span style="color: black;">&#91;</span>i<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p>I split up the code into two separate modules, sg.py (which just does specific gravity adjustment) and abv.py (which does ABV calualation). Splitting the code up enables me to take SG measurements and adjust based on temperature, without doing a full ABV measurement. In sg.py the reverse adjusted SG is what you would need to read from the hydrometer at the specified temperature, in order to achieve the adjusted reading you specified.</p>
<p>Since the calculations are fairly trivial the main bulk of the code is in the user interfaces. I implemented a simple command line interface which either takes arguments from the command line, or prompts the user via the python input() function. I also use the SL4A API to implement a simple UI for Android, basically the user is prompted for each quantity by a dialog box.</p>
<p>Anyway, there&#8217;s not much else to say, except that <a href="http://gitorious.org/python-tools">I&#8217;ve put the code up on Gitorious</a> for anyone who wants it (it&#8217;s licenced <a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPL</a>). The code is in a git repository for useful Python scripts I&#8217;ve written, right now it&#8217;s the only thing there, but I&#8217;m going to track down some of the scripts I&#8217;ve written over the years and add them too &#8211; I might even get a few blog posts out of some of them!</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2011/01/12/calculating-alcohol-by-volume-in-python-on-android/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>On Language/Platform Restrictions&#8230;</title>
		<link>http://webworxshop.com/2010/12/09/on-languageplatform-restrictions</link>
		<comments>http://webworxshop.com/2010/12/09/on-languageplatform-restrictions#comments</comments>
		<pubDate>Thu, 09 Dec 2010 01:24:52 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Rants]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[choice]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=327</guid>
		<description><![CDATA[Editorial Note: I know I said I was going to have a Kiwi Pycon Roundup, but I've been really busy recently. I'm now going to wait until the conference video/audio is posted then I can give a proper roundup and post people to the talks I found particularly interesting.

OK, today I'm having a rant. ...]]></description>
			<content:encoded><![CDATA[<p><em>Editorial Note: I know I said I was going to have a <a href="http://nz.pycon.org/">Kiwi Pycon</a> Roundup, but I&#8217;ve been really busy recently. I&#8217;m now going to wait until the conference video/audio is posted then I can give a proper roundup and post people to the talks I found particularly interesting.</em></p>
<p>OK, today I&#8217;m having a rant. This isn&#8217;t going to be an <a href="http://blog.webworxshop.com/2010/04/06/why-this-apple-fanboyism-really-hacks-me-off">ill conceived rant about a company</a>, like my last one. This one is about something of a general feeling that I&#8217;ve been getting recently. I want to talk about what I call Language/Platform restriction (I&#8217;m open to a better name). This can best be described by taking an example, the best of which is Android.</p>
<p>So, you want to develop an Android application, but you&#8217;ve got no experience in this area. So what do you do? You head over to the <a href="http://developer.android.com">Android Developer</a> site and read some of the tutorials and documentation. To your dismay you find all the code is in <a href="http://www.java.com/en/">Java</a>, but you&#8217;re a <a href="http://python.org">Python</a> programmer. There doesn&#8217;t seem to be any way to use your favourite language on Android, despite everyone claiming that Android is an open platform.</p>
<p>Granted, this example is a little contrived. The chances of any developer not knowing that Android is a Java only platform are pretty small. This isn&#8217;t even my own experience as I&#8217;m pretty good with both Java and Python (though Python is my favourite). I guess my point is that developers have preferences over which language they like to use and that these preferences seem to be being largely ignored.</p>
<p>Now, Android does have a working Python implementation as part of the <a href="http://code.google.com/p/android-scripting/">SL4A</a> project, but this is very much a scripting environment not an application development environment. There is no native access to the Android APIs that are required to develop a fully fledged application. Also, in my opinion its usefulness as a scripting environment is limited by the lack of a Free Software cron equivalent, to run scripts automatically.</p>
<p>Lest you think I&#8217;m picking on Android, this problem isn&#8217;t specific to that platform. It&#8217;s also present on The Web. &#8220;Oh No!&#8221;, I hear you cry, &#8220;The Web is an incredibly open platform, you can use any language you want!&#8221;. In some ways this is true, on the server side, yes you can pretty much use any language you want (I&#8217;ve never seen any web apps written in assembly, but I&#8217;m sure it&#8217;s possible). The client side is another matter though.</p>
<p>If we restrict ourselves the technologies which make up &#8220;The Open Web&#8221; (basically ignoring Flash and Silverlight), we really only have one option: Javascript. Now, Javascript has historically been a complete mess. Granted it&#8217;s getting a lot better with HTML5, but it still kinda sucks. It doesn&#8217;t have any proper OO (please don&#8217;t offer up that &#8220;a function is an object&#8221; crap, as a sorry excuse). It&#8217;s still pretty low level, certainly compared to Python and it seems to be &#8220;the language which syntax forgot&#8221;.</p>
<p>This worries me. It actually worries me more than the Android situation. The reason for this is that I think The Web is going to be the main application delivery platform going forward and that Free Software needs to seize on this to create a suite of Free cloud applications, just as we have for the desktop. However, the lack of a choice of languages puts me (for one) off.</p>
<p>There have been efforts to port Python to the browser, specifically <a href="http://pyjs.org/">Pyjamas</a> and <a href="http://www.skulpt.org/">Skulpt</a>. There are problems with both these implementations. Pyjamas is too tied to its own application framework (which come from <a href="http://code.google.com/webtoolkit/">Google Web Toolkit</a>) and it basically ends up bringing desktop like application programming to The Web. Maybe this isn&#8217;t a bad thing, but it seems to miss the full potential of The Web. Really what we need is something that takes advantage of all The Web&#8217;s APIs, but without having to use Javscript. Skulpt, although initially promising, does the compilation from Python to Javascript on the client side, thus multiplying the overhead in doing so by the number of clients (granted its distributed, but it still seems wasteful when this only needs doing once).</p>
<p>I should also take a minute to mention Google&#8217;s <a href="http://code.google.com/p/nativeclient/">Native Client</a> plugin. Although its not really part of the standard Open Web technology suite, it is trying to expand beyond what Flash and Silverlight offer. Basically it&#8217;s a way to run native x86 code inside a web application and expose methods through a Javascript API. You can potentially run anything in there. There are some continuing efforts to <a href="http://lackingrhoticity.blogspot.com/2009/06/python-standard-library-in-native.html">port Python to this platform</a>, but I think this is the wrong way to go too. It&#8217;s not really intended to be a full runtime, its more like a sandboxed version of <a href="http://docs.python.org/library/ctypes.html">ctypes</a> for Javascript.</p>
<p>In both these situations (Android and The Web) the best option is for native support for other languages to be added directly to the underlying virtual machine. However, this doesn&#8217;t look like it&#8217;s going to happen any time soon, so we might need some other solutions. Pyjamas and Skulpt have demonstrated that it&#8217;s certainly possible to compile Python to Javascript so I think that&#8217;s a low hanging target. I haven&#8217;t seen anything more promising than SL4A for Android yet, and porting dynamic languages to run on Dalvik strikes me as much harder (given the static nature of Java).</p>
<p>Throughout this post I&#8217;ve kind of focussed on getting Python to run on other platforms, but what I&#8217;ve said pretty much goes for <a href="http://www.perl.org/">Perl</a>, <a href="http://www.php.net/">PHP</a> or any other language. If anyone has any thoughts on this topic, or details of other projects I should check out, please get in touch. My main fear is that we&#8217;re going to end up with a situation where there is not choice of programming languages for any given platform and that some of the best languages will be left out in the cold.</p>
<p class="wp-flattr-button"></p> <p><a href="http://webworxshop.com/?flattrss_redirect&amp;id=327&amp;md5=3eb8d5e25bd9231e18d7a981afa65d50" title="Flattr" target="_blank"><img src="http://webworxshop.com/wp-content/plugins/flattr/img/flattr-badge-large.png" alt="flattr this!"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2010/12/09/on-languageplatform-restrictions/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Kiwi PyCon Day Two</title>
		<link>http://webworxshop.com/2010/11/21/kiwi-pycon-day-two</link>
		<comments>http://webworxshop.com/2010/11/21/kiwi-pycon-day-two#comments</comments>
		<pubDate>Sun, 21 Nov 2010 07:25:33 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[kiwi pycon]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=322</guid>
		<description><![CDATA[Ahoy'hoy, again. Here's my quick round up of day two of Kiwi PyCon. Here are the talks I attended:

	Keynote: "Creating Pythonic APIs" by Anthony Baxter, from Google. This was really well put together, informative and above all hilarious.
	"How Python is influencing Neuroscience Research" by Daniel Myall. Again good to see python being used for ...]]></description>
			<content:encoded><![CDATA[<p>Ahoy&#8217;hoy, again. Here&#8217;s my quick round up of day two of Kiwi PyCon. Here are the talks I attended:</p>
<ul>
<li>Keynote: &#8220;Creating Pythonic APIs&#8221; by Anthony Baxter, from Google. This was really well put together, informative and above all hilarious.</li>
<li>&#8220;How Python is influencing Neuroscience Research&#8221; by Daniel Myall. Again good to see python being used for hardcore sciencey stuff!</li>
<li>&#8220;Don&#8217;t Block the GUI&#8221; by Glenn Ramsey. An introduction to basic threading and futures, I knew most of this stuff, but it was still interesting.</li>
<li>&#8220;Python in the Datacentre&#8221; by Matt Provost, from Weta Digital. Interesting to see the internals of how Python loads, it probably explains why Python is slow on embedded systems too.</li>
<li>&#8220;Wikkid Design&#8221; by Tim Penhey. About the design of a distributed Wiki system for Launchpad. Some good take home messages around choosing modules (personal recommendation and good documentation rule!).</li>
<li>Open Spaces (Track 1): &#8220;Why aren&#8217;t we using Python 3&#8243;, &#8220;NoSQL Databases&#8221; and &#8220;Robotics and UAVs&#8221;.</li>
<li>&#8220;Demystifying Unicode&#8221; by Leon Matthews. I knew nothing about unicode before this, now I know how to use it and that I should be using it!</li>
<li>&#8220;Teaching Computer Science with Python&#8221; by Carl Cerecke. An interesting look into the Canterbury CS Department&#8217;s moves towards Python for teaching.</li>
</ul>
<p>That&#8217;s it for now, there will be more in my full round up, which I&#8217;ll write when I have time (sometime this week). Bye for now!</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2010/11/21/kiwi-pycon-day-two/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Kiwi PyCon Day One&#8230;</title>
		<link>http://webworxshop.com/2010/11/20/kiwi-pycon-day-one</link>
		<comments>http://webworxshop.com/2010/11/20/kiwi-pycon-day-one#comments</comments>
		<pubDate>Sat, 20 Nov 2010 06:40:29 +0000</pubDate>
		<dc:creator>Rob Connolly</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[awesome]]></category>
		<category><![CDATA[conference]]></category>
		<category><![CDATA[foss]]></category>
		<category><![CDATA[kiwi pycon]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://blog.webworxshop.com/?p=284</guid>
		<description><![CDATA[So I said I'd try to blog about Kiwi PyCon over the weekend, so here goes! This is just going to be a quick post going through a few highlights, I'll save my detailed discussion for my full round up when I get back home.

So here's the talks I attended:

	Keynote (obviously) - "How I ...]]></description>
			<content:encoded><![CDATA[<p>So I said I&#8217;d try to blog about Kiwi PyCon over the weekend, so here goes! This is just going to be a quick post going through a few highlights, I&#8217;ll save my detailed discussion for my full round up when I get back home.</p>
<p>So here&#8217;s the talks I attended:</p>
<ul>
<li>Keynote (obviously) &#8211; &#8220;How I learned to stop worrying and love deployment&#8221; by Jacob Kaplan-Moss (a core Django developer). This turned me onto a few modules, which I need to take a look at some point.</li>
<li>&#8220;Freeing the Cloud one (small) service at a time&#8221; by <a href="http://identi.ca/fmarier">Francois Marier</a> &#8211; about free web services and his service, <a href="http://libravatar.com">Libravatar</a>, in particular (Francois was also kind enough to help me out with a problem I was having with it right there and then, thanks Francois).</li>
<li>&#8220;Building a distributed Key-Value store with Cassandra&#8221; by Aaron Morton from Weta Digital. This was interesting, though I think a lot of it went over my head!</li>
<li>&#8220;Packaging and Virtual Environments&#8221; by Brett Wilkins (and another presenter, who&#8217;s name I can&#8217;t remember &#8211; so sorry to him!). This was really good and turned me onto <a href="http://packages.python.org/distribute/">distribute</a>, which is a setuptools replacement. I love the image on their website:</li>
</ul>
<ul>
<li><img class="aligncenter" src="http://python-distribute.org/pip_distribute.png" alt="" width="490" height="368" />Lightning talks &#8211; Of which the one on <a href="http://bottle.paws.de/docs/dev/index.html">Bottle</a> was particularly interesting &#8211; I&#8217;ve been looking for a lightweight web framework to play around with, so I&#8217;ll give it a try.</li>
<li>&#8220;5 Good Reasons for Automated Testing&#8221; by Roman Joost. Yeah, I really should be using automated testing!</li>
<li>&#8220;An Opinionated Guide to what makes a Good Unit Test&#8221; by Michael Hudson Doyle. Reinforced the opinion expressed above!</li>
<li>&#8220;Amazon Web Service: An Introduction&#8221; by Simone Brunozzi. This was quite businessy, but this stuff is definitely on my &#8220;must check out&#8221; list.</li>
<li>&#8220;Python In Astronomy&#8221; by Ian Bond. I missed the beginning of this but it&#8217;s awesome to see Python being used to do some hardcore science &#8211; finding planets no less!</li>
</ul>
<p>Well that&#8217;s my quick summary of day one, hopefully there&#8217;ll be more good stuff tomorrow, so I&#8217;ll &#8216;see&#8217; you then.</p>
<p class="wp-flattr-button"></p>]]></content:encoded>
			<wfw:commentRss>http://webworxshop.com/2010/11/20/kiwi-pycon-day-one/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

