<?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/"
	
	xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Slacy's Blog</title>
	<atom:link href="http://slacy.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://slacy.com/blog</link>
	<description>This site is solar powered!</description>
	<lastBuildDate>Thu, 02 Sep 2010 20:12:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Transcript of Radiolab&#8217;s &#8220;Words&#8221; episode for the hearing impaired.</title>
		<link>http://slacy.com/blog/2010/09/transcript-of-radiolabs-words-episode-for-the-hearing-impaired/</link>
		<comments>http://slacy.com/blog/2010/09/transcript-of-radiolabs-words-episode-for-the-hearing-impaired/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 20:12:28 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1327</guid>
		<description><![CDATA[When I heard the Radiolab episode &#8220;Words&#8221; on their podcast, one of the first things that came to mind was sharing the story of the deaf children in Nicaragua with a deaf friend of mine.  I spent a few minutes &#8230; <a href="http://slacy.com/blog/2010/09/transcript-of-radiolabs-words-episode-for-the-hearing-impaired/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I heard the Radiolab episode &#8220;<a href="http://www.radiolab.org/2010/aug/09/new-words-new-world/">Words</a>&#8221; on their <a href="http://www.radiolab.org/feeds/podcast/">podcast</a>, one of the first things that came to mind was sharing the story of the deaf children in Nicaragua with a deaf friend of mine.  I spent a few minutes trying to find a transcript on their website, and as far as I could tell, there was none.  I sent them a quick e-mail a few weeks ago, and today they responded, with a link to a <a href="http://www.radiolab.org/2010/aug/09/transcript/">full transcript of the show</a>!</p>
<p>Huge thanks to Tim at Radiolab!</p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/09/transcript-of-radiolabs-words-episode-for-the-hearing-impaired/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>Python datetime quiz</title>
		<link>http://slacy.com/blog/2010/09/python-datetime-quiz/</link>
		<comments>http://slacy.com/blog/2010/09/python-datetime-quiz/#comments</comments>
		<pubDate>Wed, 01 Sep 2010 22:06:58 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1321</guid>
		<description><![CDATA[Without looking at the documentation (or running the code), describe the outputs of the following 4 function calls: from datetime import datetime datetime.datetime.now() datetime.datetime.today() datetime.datetime.now().date() datetime.datetime.today().date() Post your answers as a comment.]]></description>
			<content:encoded><![CDATA[<p>Without looking at the documentation (or running the code), describe the outputs of the following 4 function calls:</p>
<pre>from datetime import datetime

datetime.datetime.now()
datetime.datetime.today()
datetime.datetime.now().date()
datetime.datetime.today().date()</pre>
<p>Post your answers as a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/09/python-datetime-quiz/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
	</item>
		<item>
		<title>Pitfalls of Python&#8217;s &#8216;is&#8217; operator</title>
		<link>http://slacy.com/blog/2010/08/pitfalls-of-pythons-is-operator/</link>
		<comments>http://slacy.com/blog/2010/08/pitfalls-of-pythons-is-operator/#comments</comments>
		<pubDate>Fri, 20 Aug 2010 17:07:13 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[comparison]]></category>
		<category><![CDATA[integer]]></category>
		<category><![CDATA[is operator]]></category>
		<category><![CDATA[long]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1317</guid>
		<description><![CDATA[I saw this post on Friendfeed, and thought I&#8217;d reproduce the code here, because it&#8217;s a really interesting Python snippet, and to me, basically says never, ever use the &#8216;is&#8217; operator.  Here&#8217;s the snippet that I just reproduced on Python &#8230; <a href="http://slacy.com/blog/2010/08/pitfalls-of-pythons-is-operator/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I saw <a href="http://friendfeed.com/python/826795fd/is-not-b-but-p-q-guess-why">this post on Friendfeed</a>, and thought I&#8217;d reproduce the code here, because it&#8217;s a really interesting Python snippet, and to me, basically says <strong>never, ever use the &#8216;is&#8217; operator</strong>.  Here&#8217;s the snippet that I just reproduced on Python 2.5.2 and 2.6.5:</p>
<pre>In [1]: a = 500

In [2]: b = 500

In [3]: a == b
Out[3]: True

In [4]: a is b
<span style="font-weight: bold; font-family: Courier, fixed;">Out[4]: False</span>

In [5]: p = 50 

In [6]: q = 50

In [7]: p is q
<span style="font-weight: bold; font-family: Courier, fixed;">Out[7]: True</span></pre>
<p>Totally crazy, right?</p>
<p>The &#8216;is&#8217; operator is testing &#8220;are these objects completely identical&#8221;  In other words, are they pointing at the same implementation.  For basic types like integer, things get complicated, because Python treats integer values between -5 and 256 differently.   There&#8217;s some hint at this when looking at the documentation for the function PyInt_FromLong(), which takes a C++ long and returns the Python integer representation of that object.  The comment there says:</p>
<blockquote><p>The current implementation keeps an array of integer objects for all integers between -5 and 256, when you create an int in that range you actually just get back a reference to the existing object.</p></blockquote>
<p>And thus, values <strong>outside</strong> of that range have different implementations, and thus, return False when comparing via &#8216;is&#8217;.  There&#8217;s also some discussion of this on <a href="http://stackoverflow.com/questions/306313/">StackOverflow</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/08/pitfalls-of-pythons-is-operator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
	</item>
		<item>
		<title>5 Things you think upgrading your computer software is going to do.</title>
		<link>http://slacy.com/blog/2010/07/5-things-you-think-upgrading-your-computer-software-is-going-to-do/</link>
		<comments>http://slacy.com/blog/2010/07/5-things-you-think-upgrading-your-computer-software-is-going-to-do/#comments</comments>
		<pubDate>Sat, 31 Jul 2010 08:05:32 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1312</guid>
		<description><![CDATA[When you upgrade your computer&#8217;s OS or some big program, you&#8217;re always doing it for a reason.  Here they are: Upgrading is going to support the drivers for that new device you just got. (Sorry, it won&#8217;t.) Upgrading is going &#8230; <a href="http://slacy.com/blog/2010/07/5-things-you-think-upgrading-your-computer-software-is-going-to-do/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When you upgrade your computer&#8217;s OS or some big program, you&#8217;re always doing it for a reason.  Here they are:</p>
<ol>
<li>Upgrading is going to support the drivers for that new device you just got. (Sorry, it won&#8217;t.)</li>
<li>Upgrading is going to make your computer faster. (Really?)</li>
<li>Upgrading is going to make your computer crash less. (Actually, more.)</li>
<li>Upgrading is going to make that one program not hoze your whole system anymore. (That program has been removed from the distribution.)</li>
<li>Upgrading is going to give you lots of great, new features. (You really think things have changed that much?)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/07/5-things-you-think-upgrading-your-computer-software-is-going-to-do/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>Using Django&#8217;s widthratio template tag for multiplication &amp; division.</title>
		<link>http://slacy.com/blog/2010/07/using-djangos-widthratio-template-tag-for-multiplication-division/</link>
		<comments>http://slacy.com/blog/2010/07/using-djangos-widthratio-template-tag-for-multiplication-division/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 21:46:41 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1310</guid>
		<description><![CDATA[I find it a bit odd that Django has a template filter for adding values, but none for multiplication and division. It&#8217;s fairly straightforward to add your own math tags or filters, but why bother if you can use the &#8230; <a href="http://slacy.com/blog/2010/07/using-djangos-widthratio-template-tag-for-multiplication-division/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I find it a bit odd that Django has a template filter for adding values, but none for multiplication and division.  It&#8217;s fairly straightforward to add your own math tags or filters, but why bother if you can use the built-in one for what you need? </p>
<p>Take a closer look at the widthratio template tag.  Given {% widthratio a b c %} it computes (a/b)*c</p>
<p>So, if you want to do multiplication, all you have to do is pass b=1, and the result will be a*c.  </p>
<p>Of course, you can do division by passing c=1. (a=1 would also work, but has possible rounding side effects)</p>
<p>Note: The results are rounded to an integer before returning, so this may have marginal utility for many cases. </p>
<p>So, in summary:</p>
<p>to compute A*B: {% widthratio A 1 B %}<br />
to compute A/B: {% widthratio A B 1 %}</p>
<p>And, since add is a filter and not a tag, you can always to crazy stuff like:</p>
<p>compute A^2: {% widthratio A 1 A %}<br />
compute (A+B)^2: {% widthratio A|add:B 1 A|add:B %}<br />
compute (A+B) * (C+D): {% widthratio A|add:B 1 C|add:D %} </p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/07/using-djangos-widthratio-template-tag-for-multiplication-division/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
	</item>
		<item>
		<title>How to tell when your method is on the wrong class.</title>
		<link>http://slacy.com/blog/2010/07/how-to-tell-when-your-method-is-on-the-wrong-class/</link>
		<comments>http://slacy.com/blog/2010/07/how-to-tell-when-your-method-is-on-the-wrong-class/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 19:44:20 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1304</guid>
		<description><![CDATA[1. Your code uses self on the RHS of an assignment. Here&#8217;s a Python example: class accumulator(object): def __init__(self): self.sum = 0 class value(object): def __init__(self): self.value = 0 def accumulate(self, accum_instance): accum_instance.sum += self.value Instead of saying: a = &#8230; <a href="http://slacy.com/blog/2010/07/how-to-tell-when-your-method-is-on-the-wrong-class/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<h2>1. Your code uses self on the RHS of an assignment.</h2>
<p>Here&#8217;s a Python example:</p>
<pre>class accumulator(object):
  def __init__(self):
    self.sum = 0 

class value(object):
  def __init__(self):
    self.value = 0 

  def accumulate(self, accum_instance):
     accum_instance.sum += <strong>self.value</strong></pre>
<p>Instead of saying:</p>
<pre>a = accumulator()
v = value()
v.accumulate(a)</pre>
<p>These methods should be re-arranged such that we don&#8217;t have &#8220;self.value&#8221; on the RHS of the assignment in the accumulate method, which would make our calling code look like this:</p>
<pre>a = accumulator()
v = value()
a.accumulate(v)</pre>
<p>The calling actually looks quite similar, but the semantics of who&#8217;s responsible for the work is more clear.</p>
<h2>2. You have method names like &#8220;add_to&#8221;, &#8220;increment_by&#8221;, &#8220;combine_with&#8221; or &#8220;compute_from&#8221;</h2>
<p>Instead of calling &#8220;self.increment_by(bar)&#8221; you should likely be calling &#8220;bar.increment(self)&#8221;</p>
<p>Note, this violates one of my rules below of passing only &#8220;self&#8221; as a method argument.  At some point, the difference between foo.method(self) and self.method(foo) becomes subjective, and it&#8217;s your job as the programmer to decide how these pieces of code relate to each other, and where the functional separation lies.  The best way to decide issues like this is to try to come up with some rule for where methods live and behave.  The exact guts of &#8220;method&#8221; would need to be known &#8212; is it modifying self, or it&#8217;s argument, or both?  Try to come up with a rule like &#8220;treat arguments as const wherever possible&#8221; and you may find that these issues sort themselves out.  You may even find that splitting a class up, or joining two classes together might be a good solution to make your code more readable.</p>
<h2>3. Your method doesn&#8217;t use &#8220;self&#8221; at all, or only very minimally.</h2>
<p>Here&#8217;s another surprisingly common practice, a method that looks like this:</p>
<pre>def some_method(self, foo, bar, baz):
  self.counter += 1
  foo.process(bar)
  bar.aggregate()
  baz.compute_from(bar)</pre>
<p>This method should likely live somewhere outside of the current class, and in the classes<br />
of foo, bar, or baz.</p>
<h2>4. You&#8217;re passing self (and no other arguments) as an argument to another method.</h2>
<p>If you have code that says:</p>
<pre>some_class.some_method(self)</pre>
<p>Then you likely want to say:</p>
<pre>self.better_method(some_class)</pre>
<p>Similarly, passing a handful of member variables from self to another method is an indication that method should live in the current class.  For example:</p>
<pre>some_class.some_method(self.foo, self.bar, self.baz)</pre>
<p>could be rewritten as:</p>
<pre>self.better_method(some_class)</pre>
<p>Unless better_method would end up violating more of these rules. <img src='http://slacy.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>5. Your method delegates most of it&#8217;s functionality to another class or module.</h2>
<p>For example:</p>
<pre>def some_method(totally_reasonable_argument):
  other_class.process(totally_reasonable_argument)
  other_class.member_variable += self.size
  other_class.log(totally_reasonable_argument)</pre>
<p>Look how every line calls into functions in other_class (which could also be a module).  Clearly, this method should be living inside other_class and not on the current class.</p>
<h2>6. Your method returns an instance of a different class.</h2>
<p>For example:</p>
<pre>class SomeClass(object):
  def generate_something(foo, bar):
    # likely some computation involving foo &amp; bar here...
    # but, we're returning an instance of a totally different class.
    # This method should likely be split into 2 pieces, one living here,
    # and another piece in class something.
    return something(foo, bar)</pre>
<p>Of course, there&#8217;s always a time and a place for a factory method, but in Python, these should actually be fairly few and far between.</p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/07/how-to-tell-when-your-method-is-on-the-wrong-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
	</item>
		<item>
		<title>Best error message I&#8217;ve seen in a long time.</title>
		<link>http://slacy.com/blog/2010/07/best-error-message-ive-seen-in-a-long-time/</link>
		<comments>http://slacy.com/blog/2010/07/best-error-message-ive-seen-in-a-long-time/#comments</comments>
		<pubDate>Wed, 28 Jul 2010 16:41:50 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1301</guid>
		<description><![CDATA[This came from a Gnome-enabled program on by Ubuntu 10.04 system.  It pretty much sums up what&#8217;s wrong with &#8220;Linux on the desktop&#8221; Error setting value: No database available to save your configuration: Unable to store a value at key &#8230; <a href="http://slacy.com/blog/2010/07/best-error-message-ive-seen-in-a-long-time/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This came from a Gnome-enabled program on by Ubuntu 10.04 system.  It pretty much sums up what&#8217;s wrong with &#8220;Linux on the desktop&#8221;</p>
<blockquote><p><span style="font-family: Georgia, 'Bitstream Charter', serif; color: #444444;"><span style="line-height: 22px;">Error setting value: No database available to save your configuration: Unable to store a value at key &#8216;/desktop/gnome/url-handlers/unknown/command&#8217;, as the configuration server has no writable databases. There are some common causes of this problem: 1) your configuration path file /etc/gconf/2/path doesn&#8217;t contain any databases or wasn&#8217;t found 2) somehow we mistakenly created two gconfd processes 3) your operating system is misconfigured so NFS file locking doesn&#8217;t work in your home directory or 4) your NFS client machine crashed and didn&#8217;t properly notify the server on reboot that file locks should be dropped. If you have two gconfd processes (or had two at the time the second was launched), logging out, killing all copies of gconfd, and logging back in may help. If you have stale locks, remove ~/.gconf*/*lock. Perhaps the problem is that you attempted to use GConf from two machines at once, and ORBit still has its default configuration that prevents remote CORBA connections &#8211; put &#8220;ORBIIOPIPv4=1&#8243; in /etc/orbitrc. As always, check the user.* syslog for details on problems gconfd encountered. There can only be one gconfd per home directory, and it must own a lockfile in ~/.gconfd and also lockfiles in individual storage locations such as ~/.gconf</span></span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/07/best-error-message-ive-seen-in-a-long-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
	</item>
		<item>
		<title>Hey Flipboard!  Those are my kids!</title>
		<link>http://slacy.com/blog/2010/07/hey-flipboard/</link>
		<comments>http://slacy.com/blog/2010/07/hey-flipboard/#comments</comments>
		<pubDate>Wed, 21 Jul 2010 18:34:46 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1290</guid>
		<description><![CDATA[So, the press is somewhat buzzing about the new Flipboard iPad app, as well as their acquisition of Ellerdale.  Here&#8217;s a screenshot of the second page of their slideshow: (click to zoom).  The large image of the kid with the &#8230; <a href="http://slacy.com/blog/2010/07/hey-flipboard/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, the press is somewhat buzzing about the new <a href="http://flipboard.com">Flipboard</a> iPad app, as well as their acquisition of <a href="http://ellerdale.com">Ellerdale</a>.  Here&#8217;s a screenshot of the second page of their slideshow:</p>
<p style="text-align: center;"><a href="http://slacy.com/blog/wp-content/uploads/2010/07/flipboard2.png"><img class="aligncenter size-full wp-image-1295" title="flipboard2" src="http://slacy.com/blog/wp-content/uploads/2010/07/flipboard2.png" alt="" width="618" height="395" /></a></p>
<p>(click to zoom).  The large image of the kid with the blue hat is my daughter Maya, and my son is standing behind her (wearing a green shirt and orange hat).  We took that photo when we were goofing off at the Palo Alto JJC a couple of weeks ago!  Here&#8217;s the original source photo that I downloaded from my wife&#8217;s FB account:</p>
<p><a href="http://slacy.com/blog/wp-content/uploads/2010/07/34289_410152808354_518733354_4706418_7258516_n.jpg"><img class="aligncenter size-full wp-image-1292" title="34289_410152808354_518733354_4706418_7258516_n" src="http://slacy.com/blog/wp-content/uploads/2010/07/34289_410152808354_518733354_4706418_7258516_n.jpg" alt="" width="539" height="720" /></a>Awesome!</p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/07/hey-flipboard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:thumbnail url="http://slacy.com/blog/wp-content/uploads/2010/07/flipboard2-150x150.png" />
		<media:content url="http://slacy.com/blog/wp-content/uploads/2010/07/flipboard2.png" medium="image">
			<media:title type="html">flipboard2</media:title>
			<media:thumbnail url="http://slacy.com/blog/wp-content/uploads/2010/07/flipboard2-150x150.png" />
		</media:content>
		<media:content url="http://slacy.com/blog/wp-content/uploads/2010/07/34289_410152808354_518733354_4706418_7258516_n.jpg" medium="image">
			<media:title type="html">34289_410152808354_518733354_4706418_7258516_n</media:title>
			<media:thumbnail url="http://slacy.com/blog/wp-content/uploads/2010/07/34289_410152808354_518733354_4706418_7258516_n-150x150.jpg" />
		</media:content>
	</item>
		<item>
		<title>Alternative to GoDaddy DNS hosting?</title>
		<link>http://slacy.com/blog/2010/07/alternative-to-godaddy-dns-hosting/</link>
		<comments>http://slacy.com/blog/2010/07/alternative-to-godaddy-dns-hosting/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 17:55:00 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[dns]]></category>
		<category><![CDATA[godaddy]]></category>
		<category><![CDATA[hosting]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1288</guid>
		<description><![CDATA[I&#8217;ve heard that GoDaddy is a pretty crappy DNS service. Generally, people seem to complain that their origin DNS servers are quite slow. I have observed that every once in a while, I do get quite slow DNS resolution of &#8230; <a href="http://slacy.com/blog/2010/07/alternative-to-godaddy-dns-hosting/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve heard that GoDaddy is a pretty crappy DNS service.  Generally, people seem to complain that their origin DNS servers are quite slow.</p>
<p>I have observed that every once in a while, I do get quite slow DNS resolution of my GoDaddy hosted domains, and would switch if there was an easy (and free) alternative.</p>
<p>I&#8217;m surprised that OpenDNS and Google Public DNS don&#8217;t let people add their own DNS records for their domains.  This seems to me like a natural extension to the services they&#8217;re providing.</p>
<p>I&#8217;d love to hear if you have any alternatives to GoDaddy that are &#8220;known better&#8221; in their response times, and that are reputable and reliable.   Self-hosting DNS has always seemed like a bad idea to me, but it could be an alternative if the arguments for it are strong enough.</p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/07/alternative-to-godaddy-dns-hosting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
	</item>
		<item>
		<title>More Python style discussions.</title>
		<link>http://slacy.com/blog/2010/07/more-python-style-discussions/</link>
		<comments>http://slacy.com/blog/2010/07/more-python-style-discussions/#comments</comments>
		<pubDate>Wed, 14 Jul 2010 21:38:22 +0000</pubDate>
		<dc:creator>slacy</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://slacy.com/blog/?p=1286</guid>
		<description><![CDATA[So, I work with a lot of code that likes to do stuff like this: def process(some_dict, some_key): sum = 0 value = some_dict.get(some_key, None) if value is not None: sum += value return sum but I find the use &#8230; <a href="http://slacy.com/blog/2010/07/more-python-style-discussions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So, I work with a lot of code that likes to do stuff like this:</p>
<pre>def process(some_dict, some_key):
  sum = 0
  value = some_dict.get(some_key, None)
  if value is not None:
    sum += value
  return sum
</pre>
<p>but I find the use of get() to be really gratuitous (especially in this case) and would rather write:</p>
<pre>def process(some_dict, some_key):
  sum = 0
  if some_key not in some_dict:
    return sum
  sum += some_dict[some_key]
  return sum
</pre>
<p>But I&#8217;m sympathetic to the original author&#8217;s form, because in my form, I&#8217;m querying the dict twice, whereas in theirs, they&#8217;re doing it once.  I guess another alternative would be:</p>
<pre>def process(some_dict, some_key):
  sum = 0
  try:
    sum += some_dict[some_key]
  except KeyError:
    pass
  return sum
</pre>
<p>I&#8217;d love to hear your thoughts on which of these is the most Pythonic (or maintainable, or readable) form for this kind of logic.  </p>
<p>Note that these examples are purely synthetic, and there&#8217;s usually an extra set of looping to calculate the sum.  I&#8217;ve just simplified things to make it look nice. </p>
]]></content:encoded>
			<wfw:commentRss>http://slacy.com/blog/2010/07/more-python-style-discussions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
	</item>
	</channel>
</rss>
