<?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>java rants &#187; gae</title>
	<atom:link href="http://www.javarants.com/tag/gae/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.javarants.com</link>
	<description>Rants about Java and other internet technologies by Sam Pullara</description>
	<lastBuildDate>Thu, 11 Mar 2010 23:26:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Idiomatic Python?</title>
		<link>http://www.javarants.com/2008/04/23/idiomatic-python/</link>
		<comments>http://www.javarants.com/2008/04/23/idiomatic-python/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 18:19:51 +0000</pubDate>
		<dc:creator>Sam Pullara</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[gae]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[pipes]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.javarants.com/?p=873</guid>
		<description><![CDATA[I&#8217;ve been working my way through compiling Java into Python code but the Python back end of my isn&#8217;t that good (my brain).  I would call my stage of Python development the &#8220;magic incantation&#8221; stage.  This is the stage where you really aren&#8217;t comfortable yet with the way things work in a new [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working my way through compiling Java into Python code but the Python back end of my isn&#8217;t that good (my brain).  I would call my stage of Python development the &#8220;magic incantation&#8221; stage.  This is the stage where you really aren&#8217;t comfortable yet with the way things work in a new language but you can still get things done by miming other developers.  I&#8217;ve also had some help from some friends on <a href="http://twitter.com/spullara">Twitter</a>: @<a href="http://twitter.com/lhl">lhl</a>, @<a href="http://twitter.com/precipice">precipice</a> and @<a href="http://twitter.com/jkwatson">jkwatson</a>.  My distributed information system is now getting some redundancy.  Little did they know that I was doing parallel invocations of identical requests for reliability and incrementally higher performance &#8212; and the results were verified using a quorum of responders.<br />
<span id="more-873"></span><br />
Here is my first service that I am porting.  It takes an RSS feed (in JSON format from Pipes) and combines all the entries from each day into a single entry:</p>
<pre>
import logging
import wsgiref.handlers

from datetime import date
from google.appengine.ext import webapp
from django.utils import simplejson

class DayBinPipesWebService (webapp.RequestHandler):
 def post(self):
 	now = date.today()
 	now = now.strftime("%m/%d/%Y")
 	data = self.request.get("data")
 	items = simplejson.loads(data)["items"]
 	bins = {}
 	for item in items:
 		published = item["y:published"]
 		updateDay = "%(month)02d/%(day)02d/%(year)04d" % published
 		if now != updateDay:
 			bin = bins.get(updateDay, [])
 			bin.append(item)
 			bins[updateDay] = bin
 	entries = []
 	for bin in bins.items():
 		dayDate = bin[0]
 		binEntries = bin[1]
 		first = binEntries[0].copy()
 		first["description"] = ""
 		for e in binEntries:
 			first["description"] += "&lt;p&gt;&lt;a href='%(link)s'&gt;%(title)s&lt;/a&gt;&lt;br&gt;%(description)s&lt;/p&gt;" % e
 		first["title"] = "Items from " + dayDate
 		first["link"] = ""
 		entries.append(first)
 	self.response.content_type = "application/json"
 	simplejson.dump(entries, self.response.out)
</pre>
<p>How would you write this in idiomatic Python as opposed to my rudimentary translation?  Would you change the whole design?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.javarants.com/2008/04/23/idiomatic-python/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
