<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Jot Notes &#187; Python</title>
	<atom:link href="http://blog.myjotnotes.com/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.myjotnotes.com</link>
	<description>Random notes about software development</description>
	<lastBuildDate>Wed, 01 Feb 2012 20:51:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.myjotnotes.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Jot Notes &#187; Python</title>
		<link>http://blog.myjotnotes.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.myjotnotes.com/osd.xml" title="Jot Notes" />
	<atom:link rel='hub' href='http://blog.myjotnotes.com/?pushpress=hub'/>
		<item>
		<title>Bizarre Python File Error</title>
		<link>http://blog.myjotnotes.com/2008/07/08/bizarre-python-file-error/</link>
		<comments>http://blog.myjotnotes.com/2008/07/08/bizarre-python-file-error/#comments</comments>
		<pubDate>Tue, 08 Jul 2008 20:39:44 +0000</pubDate>
		<dc:creator>somejotnotes</dc:creator>
				<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://jotnotes.wordpress.com/?p=32</guid>
		<description><![CDATA[Update (December 21, 2008): I tried running the code in this blog post today, and I was unable to reproduce this bug using Python 2.5.2. Therefore, I don&#8217;t know how useful the information in this post is. I have decided to leave this post up in the off chance that it might help somebody anyway. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.myjotnotes.com&amp;blog=3897530&amp;post=32&amp;subd=jotnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><span style="background-color:#FFFBCC;">Update (December 21, 2008): I tried running the code in this blog post today, and I was unable to reproduce this bug using Python 2.5.2.  Therefore, I don&#8217;t know how useful the information in this post is.  I have decided to leave this post up in the off chance that it might help somebody anyway.</span></p>
<p>I spent a couple of hours today trying to figure out this bizarre (and unhelpful) Python error message: <strong>IOError: [Errno 0] Error</strong></p>
<p>Here is some simple code which reproduces the error:</p>
<p><pre class="brush: python;">
fp = open(&quot;test.txt&quot;, &quot;r+&quot;)

while True:
    line = fp.readline()
    if not line:
        break

fp.write(&quot;some new text&quot;)
</pre></p>
<p>It seems that once readline reaches the end of the file, you can no longer write to that file.</p>
<p>Note that you can get the same error if you try to read and write a config file using the ConfigParser module:</p>
<p><pre class="brush: python;">
import ConfigParser

#read config file
config = ConfigParser.ConfigParser()
configfile = open(&quot;temp.config&quot;, &quot;r+&quot;)
config.readfp(configfile)

#try to write to same file
config.set(&quot;Main&quot;, &quot;tempDir&quot;, &quot;C:\\temp&quot;)
config.write(configfile)
configfile.close()
</pre></p>
<p>You can get around this error by closing the file after calling the readfp method, and then reopening the file if you want to write to it.</p>
<p><pre class="brush: python;">
import ConfigParser

#read config file
config = ConfigParser.ConfigParser()
configfile = open(&quot;temp.config&quot;, &quot;r&quot;)
config.readfp(configfile)
configfile.close()

#write config file
config.set(&quot;Main&quot;, &quot;tempDir&quot;, &quot;C:\\temp&quot;)
configfile = open(&quot;temp.config&quot;, &quot;w&quot;)
config.write(configfile)
configfile.close()
</pre></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/jotnotes.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/jotnotes.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jotnotes.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jotnotes.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jotnotes.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jotnotes.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jotnotes.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jotnotes.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jotnotes.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jotnotes.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jotnotes.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jotnotes.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jotnotes.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jotnotes.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jotnotes.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jotnotes.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.myjotnotes.com&amp;blog=3897530&amp;post=32&amp;subd=jotnotes&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.myjotnotes.com/2008/07/08/bizarre-python-file-error/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">somejotnotes</media:title>
		</media:content>
	</item>
	</channel>
</rss>
