<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2" -->
<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/"
	>

<channel>
	<title>Eli Bendersky's website</title>
	<link>http://eli.thegreenplace.net</link>
	<description>Eli Bendersky's personal website</description>
	<pubDate>Fri, 04 Jul 2008 05:45:01 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2</generator>
	<language>en</language>
			<item>
		<title>libcollect - collecting Python distributions</title>
		<link>http://eli.thegreenplace.net/2008/07/03/libcollect-collecting-python-distributions/</link>
		<comments>http://eli.thegreenplace.net/2008/07/03/libcollect-collecting-python-distributions/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 17:05:33 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/07/03/libcollect-collecting-python-distributions/</guid>
		<description><![CDATA[Here&#8217;s an excerpt from the documentation of libcollect:
Motivation:
Imagine that you&#8217;ve written a script that uses several libraries, some of which you&#8217;ve written and some you&#8217;ve downloaded and installed (for example PyYAML). You want to distribute the script to your friends and co-workers, who already have Python installed with all the standard library. But your script [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an excerpt from the documentation of <a href="http://eli.thegreenplace.net/files/prog_code/libcollect.py.txt">libcollect</a>:</p>
<blockquote><p>Motivation:</p>
<p>Imagine that you&#8217;ve written a script that uses several libraries, some of which you&#8217;ve written and some you&#8217;ve downloaded and installed (for example PyYAML). You want to distribute the script to your friends and co-workers, who already have Python installed with all the standard library. But your script won&#8217;t run on their machines, because they have neither your personal libraries, nor PyYAML installed. So what can you do ?</p>
<p>* You can ask them to install PyYAML and other libraries your script uses, and send them your own libraries. This is a lengthy and inconvenient process.<br />
* You can use a tool like py2exe to package your delivery. This has a   downside, however. py2exe produces large files (several MBs) and you may not want that.<br />
* You can painstakingly collect the libraries into a directory where your script can find them, and package the directory together with the script.</p>
<p>LibCollect makes the third option trivial, by doing all the dirty work for you.
</p></blockquote>
<p><a href="http://eli.thegreenplace.net/files/prog_code/libcollect.py.txt">libcollect</a> really fills a need for me, and I&#8217;m much happier about easy distribution of my scripts after I&#8217;ve written it. I post it online in the hope that other people will find it useful as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/07/03/libcollect-collecting-python-distributions/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Collecting Python insights</title>
		<link>http://eli.thegreenplace.net/2008/07/03/collecting-python-insights/</link>
		<comments>http://eli.thegreenplace.net/2008/07/03/collecting-python-insights/#comments</comments>
		<pubDate>Thu, 03 Jul 2008 16:09:28 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/07/03/collecting-python-insights/</guid>
		<description><![CDATA[I&#8217;ve started collecting random insights on Python here. The goal is a single place, accessible online, where I can find answers on topics I&#8217;ve struggled with before.
I hope others will find the page helpful as well. If you have comments, leave them here.
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve started collecting random insights on Python <a href="http://eli.thegreenplace.net/programs-and-code/python-insights/">here</a>. The goal is a single place, accessible online, where I can find answers on topics I&#8217;ve struggled with before.</p>
<p>I hope others will find the page helpful as well. If you have comments, leave them here.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/07/03/collecting-python-insights/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Compiling Python extensions with distutils and MinGW</title>
		<link>http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/</link>
		<comments>http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/#comments</comments>
		<pubDate>Sat, 28 Jun 2008 05:32:12 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/</guid>
		<description><![CDATA[Yesterday I wrote about compiling Python 2.5 extensions using MS Visual Studio. However, I also wanted to make it work using distutils (as described here), which appeared to be the simplest method.
Trying distutils with Visual Studio 2005 Express
I have the free Visual Studio 2005 Express installed. I used it to successfully compile Python from sources, [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I wrote about compiling Python 2.5 extensions using MS Visual Studio. However, I also wanted to make it work using <code>distutils</code> (as described <a href="http://docs.python.org/ext/building.html">here</a>), which appeared to be the simplest method.</p>
<h4>Trying distutils with Visual Studio 2005 Express</h4>
<p>I have the free Visual Studio 2005 Express installed. I used it to successfully compile Python from sources, and wanted to tie it to <code>distutils</code> to compile the extension. Unfortunately, <code>distutils</code> is very strict about the MSVC version you compile extensions with, and complained:</p>
<pre>running build
running build_ext
error: Python was built with Visual Studio 2003;
extensions must be built with a compiler than can generate compatible binaries.
Visual Studio 2003 was not found on this system. If you have Cygwin installed,
you can try compiling with MingW32, by passing "-c mingw32" to setup.py.
</pre>
<p>I consulted the Python IRC channel, and got a warm recommendation to use MinGW anyway, because many people has tested its compatibility with the Python distribution.</p>
<h4>distutils with MinGW, first attempt</h4>
<p>I&#8217;ve downloaded the latest version of <a href="http://www.mingw.org/download.shtml">MinGW</a>, and tried to call <code>distutils</code> with the appropriate flag:</p>
<pre>python setup build -c mingw32
</pre>
<p>But got this error<sup class="footnote"><a href="#fn1" title="I'm using a trivial sample extension called 'hello'. Here's its C file:">1</a></sup>:</p>
<pre>running build
running build_ext
building 'hello' extension
creating build
creating buildtemp.win32-2.5
creating buildtemp.win32-2.5Release
d:mingwbingcc.exe -mno-cygwin -mdll -O -Wall -IC:Python25include -IC:Python25PC -c hellomodule.c -o buildtemp.win32-2.5Releasehellomodule.o
writing buildtemp.win32-2.5Releasehello.def
creating buildlib.win32-2.5
d:mingwbingcc.exe -mno-cygwin -shared -s buildtemp.win32-2.5Releasehellomodule.o buildtemp.win32-2.5Releasehello.def -LC:Python25libs -LC:Python25PCbuild -lpython25 -lmsvcr71 -o buildlib.win32-2.5hello.pyd
buildtemp.win32-2.5Releasehellomodule.o:hellomodule.c:(.text+0x3e): undefined reference to `_imp___Py_NoneStruct'
buildtemp.win32-2.5Releasehellomodule.o:hellomodule.c:(.text+0x46): undefined reference to `_imp___Py_NoneStruct'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
</pre>
<p>This got me stumped, because I could find nothing useful about this error in Google. However, I did get to <a href="http://boodebr.org/main/python/build-windows-extensions">this page</a>, where the solution was found in the comments.</p>
<h4>The solution</h4>
<p>Apparently, the Python export lib (<code>libs/python25.lib</code> in the Python distribution) is <a href="http://www.mingw.org/MinGWiki/index.php/CreateImportLibraries">not good enough for MinGW</a>, and it wants a Unix-y <code>.a</code> file to list the exports of Python&#8217;s DLL (the one where the interpreter itself lives).</p>
<p>So you have to create <code>libpython25.a</code> file for the Python library. If you want, download <a href="http://eli.thegreenplace.net/files/permakeep/libpython25.a">the one I&#8217;ve created</a> and skip all these steps. It should work with Python 2.5</p>
<p>To create <code>libpython25.a</code> on your own (taken from <a href="http://sebsauvage.net/python/mingw.html">here</a> with minor modifications):</p>
<ol>
<li>Find <code>python25.dll</code> (it will probably be in <code>windows/system32</code>)</li>
<li>Now you have to list the exports from this DLL. Several tools can do this (including <code>dumpbin</code>), but <code>pexports</code> is the most convenient for this task. Get it from <a href="http://www.emmestech.com/software/pexports-0.43/pexports-0.43.zip">here</a> or  <a href="http://eli.thegreenplace.net/files/permakeep/pexports.exe">here</a> (I&#8217;ll keep this link alive for a long time, promise).</li>
<li>Run <code>pexports.exe python25.dll &gt; python25.def</code></li>
<li>Now, if you&#8217;ve installed MinGW and added its <code>bin</code> directory to your path, you should be able to just call <code>dlltool</code> (a utility that comes with MinGW): <code>dlltool --dllname python25.dll --def python 25.def --output-lib libpython25.a</code></li>
<li>This has created <code>libpython25.a</code></li>
</ol>
<p>Now just place <code>libpython25.a</code> in the <code>libs</code> directory of your Python distribution, and run <code>distutils</code> again<sup class="footnote"><a href="#fn2" title="Note that you can run either setup.py build -c mingw32 or setup.py build --compiler=mingw32 - they are suggested in different places, but actually mean the same.">2</a></sup>:</p>
<pre>running build
running build_ext
building 'hello' extension
creating build
creating buildtemp.win32-2.5
creating buildtemp.win32-2.5Release
d:mingwbingcc.exe -mno-cygwin -mdll -O -Wall -IC:Python25include -IC:Python25PC -c hellomodule.c -o buildtemp.win32-2.5Releasehellomodule.o
writing buildtemp.win32-2.5Releasehello.def
creating buildlib.win32-2.5
d:mingwbingcc.exe -mno-cygwin -shared -s buildtemp.win32-2.5Releasehellomodule.o buildtemp.win32-2.5Releasehello.def -LC:Python25libs -LC:Python25PCbuild -lpython25 -lmsvcr71 -o buildlib.win32-2.5hello.pyd
</pre>
<p>Big success ! You can now use the extension from your Python code.</p>
<h4>Updates</h4>
<ul>
<li>It has been mentioned in a couple of places that with the latest MinGW the <code>.a</code> file is no longer needed and it&#8217;s enough to place the Python DLL in <code>libs</code>. I&#8217;m using the latest MinGW, ActiveState Python and <code>distutils</code>, and it didn&#8217;t work for me that way.</li>
</ul>
<p><center><img src='http://eli.thegreenplace.net/wp-content/uploads/hline.jpg' alt='' width="320" height="5" /></center></p>
<p class="footnote" id="fn1"><sup>1</sup> I&#8217;m using a trivial sample extension called &#8216;hello&#8217;. Here&#8217;s its C file:</p>

<div class="wp_syntax"><div class="code"><pre class="c"><span style="color: #339933;">#include &lt;Python.h&gt;</span>
&nbsp;
<span style="color: black;">static</span> PyObject<span style="color: black;">*</span> say_hello<span style="color: black;">&#40;</span>PyObject<span style="color: black;">*</span> self, PyObject<span style="color: black;">*</span> args<span style="color: black;">&#41;</span>
<span style="color: black;">&#123;</span>
    <span style="color: black;">const</span> <span style="color: black;">char</span><span style="color: black;">*</span> name;
&nbsp;
    <span style="color: blue; font-weight: bold;">if</span> <span style="color: black;">&#40;</span><span style="color: black;">!</span>PyArg_ParseTuple<span style="color: black;">&#40;</span>args, <span style="color: maroon;">&quot;s&quot;</span>, <span style="color: black;">&amp;</span>amp;name<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
        <span style="color: blue; font-weight: bold;">return</span> <span style="color: blue;">NULL</span>;
&nbsp;
    <span style="color: blue;">printf</span><span style="color: black;">&#40;</span><span style="color: maroon;">&quot;Hello %s!<span style="color: maroon;">\n</span>&quot;</span>, name<span style="color: black;">&#41;</span>;
&nbsp;
    Py_RETURN_NONE;
<span style="color: black;">&#125;</span>
&nbsp;
<span style="color: black;">static</span> PyMethodDef HelloMethods<span style="color: black;">&#91;</span><span style="color: black;">&#93;</span> <span style="color: black;">=</span>
<span style="color: black;">&#123;</span>
     <span style="color: black;">&#123;</span><span style="color: maroon;">&quot;say_hello&quot;</span>, say_hello, METH_VARARGS, <span style="color: maroon;">&quot;Greet somebody.&quot;</span><span style="color: black;">&#125;</span>,
     <span style="color: black;">&#123;</span><span style="color: blue;">NULL</span>, <span style="color: blue;">NULL</span>, <span style="color: black;">0</span>, <span style="color: blue;">NULL</span><span style="color: black;">&#125;</span>
<span style="color: black;">&#125;</span>;
&nbsp;
PyMODINIT_FUNC
&nbsp;
inithello<span style="color: black;">&#40;</span><span style="color: black;">void</span><span style="color: black;">&#41;</span>
<span style="color: black;">&#123;</span>
     <span style="color: black;">&#40;</span><span style="color: black;">void</span><span style="color: black;">&#41;</span> Py_InitModule<span style="color: black;">&#40;</span><span style="color: maroon;">&quot;hello&quot;</span>, HelloMethods<span style="color: black;">&#41;</span>;
<span style="color: black;">&#125;</span></pre></div></div>

<p>And here is the <code>distutils</code> setup file:</p>

<div class="wp_syntax"><div class="code"><pre class="python"><span style="color: blue; font-weight: bold;">from</span> <span style="color: blue;">distutils</span>.<span style="color: black;">core</span> <span style="color: blue; font-weight: bold;">import</span> setup, Extension
&nbsp;
module1 = Extension<span style="color: black;">&#40;</span><span style="color: maroon;">'hello'</span>, sources = <span style="color: black;">&#91;</span><span style="color: maroon;">'hellomodule.c'</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
&nbsp;
setup <span style="color: black;">&#40;</span>name = <span style="color: maroon;">'PackageName'</span>,
        version = <span style="color: maroon;">'1.0'</span>,
        description = <span style="color: maroon;">'This is a demo package'</span>,
        ext_modules = <span style="color: black;">&#91;</span>module1<span style="color: black;">&#93;</span><span style="color: black;">&#41;</span></pre></div></div>

<p class="footnote" id="fn2"><sup>2</sup> Note that you can run either <code>setup.py build -c mingw32</code> or <code>setup.py build --compiler=mingw32</code> - they are suggested in different places, but actually mean the same.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/28/compiling-python-extensions-with-distutils-and-mingw/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating Python extension modules in C</title>
		<link>http://eli.thegreenplace.net/2008/06/27/creating-python-extension-modules-in-c/</link>
		<comments>http://eli.thegreenplace.net/2008/06/27/creating-python-extension-modules-in-c/#comments</comments>
		<pubDate>Fri, 27 Jun 2008 06:08:29 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/27/creating-python-extension-modules-in-c/</guid>
		<description><![CDATA[I&#8217;ve successfully created a C extension for Python, basically following the instructions given here. For the compilation, I used the free Visual C++ 2005 Express (internal version 8.0)
The exact steps I followed are:

Download the Python (2.5) source distribution from http://www.python.org/
Build Python from sources with MSVC 2005 Express, in both Debug and Release configurations. For this, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve successfully created a C extension for Python, basically following the instructions given <a href="http://docs.python.org/ext/win-cookbook.html">here</a>. For the compilation, I used the free Visual C++ 2005 Express (internal version 8.0)</p>
<p>The exact steps I followed are:</p>
<ol>
<li>Download the Python (2.5) source distribution from <a href="http://www.python.org/">http://www.python.org/</a></li>
<li>Build Python from sources with MSVC 2005 Express, in both Debug and Release configurations. For this, go to the directory PCBuild in the source distribution and double click on the .sln file (Visual Studio will ask to convert it, since Python 2.5 was built on Windows with MSVC 2003). Select Debug and build solution. Then the same for Release.</li>
<li>Some libraries fail to build - this is normal. These are usually bindings to extra thing you have to install (Tk addons, bz compression, Berkley DB libs, etc). Python works fine without them.</li>
<li>Now, following the documentation instructions, I copied the \PC\example_nt directory, opened the solution contained in it, modified the Include and Linker Library directories path back to the source distribution, and built the solution.</li>
<li>example.pyd is created, and can be loaded and used by the Python interpreter.</li>
</ol>
<p>Phew, this was much easier than I expected. It&#8217;s another chance to appreciate the work that has been into Python to make it more friendly for Windows users.</p>
<p><strong>Update:</strong> You don&#8217;t even have to install the source distribution of Python to compile extensions. The binary distribution on Windows has the Include and libs/ directories that contain everything necessary to compile the extensions in Release mode. It is still recommended to have the source distribution handy, though, because it comes with a lot of examples and code from standard extensions to learn from, and you can use it to compile the extensions in Debug mode and run them with a Debug version of Python itself.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/27/creating-python-extension-modules-in-c/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book review: &#8220;Mitla Pass&#8221; by Leon Uris</title>
		<link>http://eli.thegreenplace.net/2008/06/25/book-review-mitla-pass-by-leon-uris/</link>
		<comments>http://eli.thegreenplace.net/2008/06/25/book-review-mitla-pass-by-leon-uris/#comments</comments>
		<pubDate>Wed, 25 Jun 2008 18:00:29 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Book reviews]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/25/book-review-mitla-pass-by-leon-uris/</guid>
		<description><![CDATA[I&#8217;ve really enjoyed the books of Uris I&#8217;ve read so far, especially &#8220;Exodus&#8221; and &#8220;The Haj&#8221;. So when I found out that he has another book on the subject of Israeli history, I knew I had to read it as well.
Every author has a unique signature, which you begin to recognize after reading a couple [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve really enjoyed the books of Uris I&#8217;ve read so far, especially &#8220;Exodus&#8221; and &#8220;The Haj&#8221;. So when I found out that he has another book on the subject of Israeli history, I knew I had to read it as well.</p>
<p>Every author has a unique signature, which you begin to recognize after reading a couple of his books. Uris is no different. In fact, he has several very strong signatures that come up time after time in every book. The three I&#8217;ve found to be most conspicuous are:</p>
<ol>
<li>A strong affection for Jews and dislike of Arabs. This shows most firmly in the characters. Usually, the Jew characters are moral, gallant, fair and generally very positive.</li>
<li>A tendency to digress into long side-stories, usually telling about the backgrounds of the main characters.</li>
<li>American machoism, especially in relation to the prototypical &#8220;ex-Marine&#8221; (whom Uris, unsurprisingly, is by himself)</li>
</ol>
<p>Well, while reading &#8220;Mitla Pass&#8221; I found that signature (1) is suppressed to the point of reversion, signature (2) is absurdly intensified, and signature (3) stayed the same. I&#8217;ll elaborate:</p>
<p>Somehow, in most of the background stories in this book, Uris chooses to present a lot of extremely negative Jewish characters. It appears that he did a good amount of research on all the negative stereotypes Jews have (such as weakness of character, promiscuity, parsimoniousness, nagging and complaining, the impossible nature of older women of east-European origin and so on), and did quite an effort to amplify it. I wonder at the reason for doing so. Is it that he was criticized for highlighting the positive stereotypes too much in earlier books ?</p>
<p>I have the most nits to pick with (anti-)signature (2). Uris just took it way too far with the amount of digressions in this book. Of the 500 pages, I don&#8217;t think it would be an exaggeration to say that about 10% are dedicated to the main plot, and the other 90% are spent in side-stories, mostly about the family of Gideon. Really, it appears like an un-edited version of the book. I was hoping to find interesting historical information about the life in Israel on the verge of the 1956 war in Sinai, and on the war itself, but the meager amount of text the author dedicated to the main plot made it almost trivial and completely devoid of substance.</p>
<p>I don&#8217;t want to conclude this review with a negative tone though, since I&#8217;ve liked the book, all things considered. Leon Uris definitely knows how to write, and his ability to intermix a page-turning plot with interesting historical background is awesome. While the vast amounts of digressions made the main plot useless, the side-stories themselves are very enjoyable (if you ignore the anti-Jewish stereotypes) and deal with several interesting periods of Jewish history in the late 19th and early 20th centuries.</p>
<p>So all in all, this book is recommended, although you&#8217;ll be disappointed if you look for a masterpiece like &#8220;Exodus&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/25/book-review-mitla-pass-by-leon-uris/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book review: &#8220;The conquest of the Incas&#8221; by John Hemming</title>
		<link>http://eli.thegreenplace.net/2008/06/23/book-review-the-conquest-of-the-incas-by-john-hemming/</link>
		<comments>http://eli.thegreenplace.net/2008/06/23/book-review-the-conquest-of-the-incas-by-john-hemming/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 04:45:03 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Book reviews]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/23/book-review-the-conquest-of-the-incas-by-john-hemming/</guid>
		<description><![CDATA[We bought this book in Cuzco, because I wanted a nice historical book on the Incas to read while traveling through Peru. So, after a few rounds of bartering in a couple of stores on the Plaza de las Armas, &#8220;The conquest of the Incas&#8221; was chosen.
Unfortunately, I&#8217;ve miscalculated and misunderstood the topic of the [...]]]></description>
			<content:encoded><![CDATA[<p>We bought this book in Cuzco, because I wanted a nice historical book on the Incas to read while traveling through Peru. So, after a few rounds of bartering in a couple of stores on the Plaza de las Armas, &#8220;The conquest of the Incas&#8221; was chosen.</p>
<p>Unfortunately, I&#8217;ve miscalculated and misunderstood the topic of the book. I was hoping for a book on the history of the various tribes in the region, their unification into the Inca empire, Spanish conquistadors and their subjugation of the Incas. Instead, the book focuses on the years after the initial conquest - the complex politics and relations between the Spaniards and the local population and surviving members of the Inca royal family. Not much is told on the time before the landing of Pizzaro in Peru. </p>
<p>However, the book is well written and tells its intended story in a detailed and at the same time interesting manner. So if post-conquest Peru in its first few decades is your fancy, you&#8217;ll find this book excellent.</p>
<p>This is not to say that I didn&#8217;t like the book. It had enough interesting history of both post and pre-conquest to make me satisfied, even if I flipped through some parts of it when it got too detailed with the descriptions of each new successor on the Inca puppet-throne the Spaniards instated. It&#8217;s a real history book, textbook-class, so no matter how well it&#8217;s written, it&#8217;s difficult to digest in large chunks. So I took my time with it - nearly two months of on and off reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/23/book-review-the-conquest-of-the-incas-by-john-hemming/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Productivity insigths from &#8220;Getting things done&#8221;</title>
		<link>http://eli.thegreenplace.net/2008/06/20/productivity-insigths-from-getting-things-done/</link>
		<comments>http://eli.thegreenplace.net/2008/06/20/productivity-insigths-from-getting-things-done/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 04:36:10 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Miscellanea]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/20/productivity-insigths-from-getting-things-done/</guid>
		<description><![CDATA[I&#8217;ve read David Allen&#8217;s &#8220;Getting things done&#8221; before, and yesterday I wanted to refresh my memory regarding the productivity tips it offers. 
So I skimmed through the book for a couple of hours. I think that I&#8217;m better at organization than I was in the past, so most of the tips in the book were [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve read David Allen&#8217;s &#8220;Getting things done&#8221; <a href="http://eli.thegreenplace.net/2004/07/08/book-review-getting-things-done-by-david-allen/">before</a>, and yesterday I wanted to refresh my memory regarding the productivity tips it offers. </p>
<p>So I skimmed through the book for a couple of hours. I think that I&#8217;m better at organization than I was in the past, so most of the tips in the book were quite obvious. However, I still gleaned a few interesting insights I want to file here for future review:</p>
<ul>
<li>Tasks stay on your mind and make you worry mainly because they&#8217;re unclear. Replace vague topics by concrete goals that can be acted upon. For example, if a part of your todo list now looks like:
<ul>
<li>Foo</li>
<li>Bar</li>
</ul>
<p>Replace it by:</p>
<ul>
<li>Talk to Joe about implementing Foo</li>
<li>Bar: read about super Widgets</li>
<li>Bar: implement a mega Widget for patch 12</li>
<li>Bar: do a code review</li>
</ul>
</li>
<li>
Some relevant quotes: <em>&#8220;This constant, unproductive preoccupation with all the things we have to do is the single largest consumer of time and energy&#8221;</em>. and <em>&#8220;It is easier to act yourself into a better way of feeling than to feel yourself into a better way of action&#8221;</em>
</li>
<li>You should periodically sort and empty your master to-do list. Emptying it doesn&#8217;t necessarily mean doing everything on it. Rather, all the items on the list have to be assorted to more specific locations, like a calendar, per-project to-do lists and so on. Keeping a lot of stuff on the master list for long periods of time is counterproductive.</li>
<li>Weekly reviews of your tasks and goals are very important. No matter how well we try to organize ourselves, work often gets too hectic to follow a clearly defined plan all the time. A weekly review is a method to keep it all under control in the long run. Once a week, take some time to review all your pending tasks and to-do lists and set up more concrete goals for the week to come.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/20/productivity-insigths-from-getting-things-done/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book review: &#8220;After the quake&#8221; by Haruki Murakami</title>
		<link>http://eli.thegreenplace.net/2008/06/12/book-review-after-the-quake-by-haruki-murakami/</link>
		<comments>http://eli.thegreenplace.net/2008/06/12/book-review-after-the-quake-by-haruki-murakami/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 16:49:57 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Book reviews]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/12/book-review-after-the-quake-by-haruki-murakami/</guid>
		<description><![CDATA[I picked this book up at the supermarket while waiting in the line for checkout. Began reading it and couldn&#8217;t put it down, so I bought it. A nice trick from the marketing of the supermarket&#8230;
Anyway, as the book is quite short, I&#8217;ve finished it very quickly, and then a weird thing happened - I [...]]]></description>
			<content:encoded><![CDATA[<p>I picked this book up at the supermarket while waiting in the line for checkout. Began reading it and couldn&#8217;t put it down, so I bought it. A nice trick from the marketing of the supermarket&#8230;</p>
<p>Anyway, as the book is quite short, I&#8217;ve finished it very quickly, and then a weird thing happened - I felt that I have to read it again. This has only happened to me once before, with <a href="http://eli.thegreenplace.net/2005/01/21/book-review-eugene-onegin-by-as-pushkin/">Eugene Onegin</a>. I did not read it again immediately this time though, but rather 2-3 books later, although I was certain that I should reread it and left it on the &#8220;unread&#8221; shelf. </p>
<p>&#8220;After the quake&#8221; is a set of 6 short stories that are very loosely related by the fact that they all mention the catastrophic earthquake in the city of Kobe in 1995 (well, if you leave out the obvious connection of all the plots happening in Japan, of course). I would say that the main theme of the stories is that all the characters contemplate the basic questions of human existence and worth with this traumatic event in the background. Although the characters are very different (from a salesman who travels to the north of Japan on a weird mission after his wife has left him to a successful physician who spends a relaxing vacation in Thailand), there is definitely a binding line between their contemplations.</p>
<p>I&#8217;ve only read one book of Murakami before (<a href="http://eli.thegreenplace.net/2004/09/26/book-review-norwegian-wood-by-haruki-murakami/">Norwegian Wood</a>) and found it to be charming and thoughtful in a way I can&#8217;t express precisely. I have the same feeling about this one. One thing I&#8217;m sure of is that I definitely liked it.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/12/book-review-after-the-quake-by-haruki-murakami/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Book review: &#8220;Cien años de soledad&#8221; by Gabriel García Márquez</title>
		<link>http://eli.thegreenplace.net/2008/06/09/book-review-cien-anos-de-soledad-by-gabriel-garcia-marquez/</link>
		<comments>http://eli.thegreenplace.net/2008/06/09/book-review-cien-anos-de-soledad-by-gabriel-garcia-marquez/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 09:59:55 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Spanish]]></category>

		<category><![CDATA[Book reviews]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/09/book-review-cien-anos-de-soledad-by-gabriel-garcia-marquez/</guid>
		<description><![CDATA[(read in Spanish)
Yes, I&#8217;ve finished reading &#8220;One hundred years of solitude&#8221; in Spanish. I began this endeavor months ago (somewhere in mid 2007 I reckon), and today it was completed. Why did it take so long ? For a couple of reasons, I guess. First of all, I read most of it with a dictionary [...]]]></description>
			<content:encoded><![CDATA[<p>(read in Spanish)</p>
<p>Yes, I&#8217;ve finished reading &#8220;One hundred years of solitude&#8221; in Spanish. I began this endeavor months ago (somewhere in mid 2007 I reckon), and today it was completed. Why did it take so long ? For a couple of reasons, I guess. First of all, I read most of it with a dictionary in hand, which made the pace excruciatingly slow (10 pages per hour or so). Second, the book is far from having a fluid plot that&#8217;s easy to follow, so consuming it in large quantities can be very difficult.</p>
<p>Anyway, now that it&#8217;s done, I&#8217;m proud of having finished it. I read the book before (6-7 years ago), in English. Even though my English was pretty good back then, the book was very difficult, as it used a lot of high language. I recall wondering how reading such a book in its native Spanish would feel - perhaps this is what triggered my desire to learn Spanish, though I&#8217;m not certain about this. </p>
<p>CAS (acronym of the Spanish name), as it is frequently referred to, is considered one of the most notable works of Latin literature, widely acclaimed as second only to Don Quixote. Márquez received the Nobel prize in literature for his works, of which CAS is the principal. It tells the story of the Buendía family, set in the 19th and 20th centuries in the small village Macondo (which was founded by the head of the family) in Colombia. The story deals with seven generations of the Buendías, most of which have the same name, which is a frequent criticism of the novel. </p>
<p>Naming all the family males either Aureliano or José Arcadio (or some variation thereof) is a deliberate trick by Márquez, to drill in the main theme of the book - which is the repetitiveness of time and history. Needless to say, it gets quite confusing at times, and if your book doesn&#8217;t have a helpful family tree depicted in the beginning, consult an online resource. Otherwise, it&#8217;s too easy to get lost (unless you&#8217;re reading the whole book in a single sitting - but I wonder who could do that&#8230;)</p>
<p>Another recurring theme in the book is surrealism. Insomnia that hit a whole town for weeks, rain that lasts years, yellow butterflies, increased fecundity of farm animals, colored ants and small fish made of gold are only some of the &#8220;wacky&#8221; fantasies CAS is full of. These too, are part of the theme of eternal recurrence of patterns in the lives of the Buendías.</p>
<p>And it&#8217;s impossible to write a review of this book without mentioning solitude and loneliness, that are perhaps the main feeling and state the author tries to transmit to his readers. How you&#8217;ll understand it depends on you, and I believe that everyone can see something for himself in this theme.</p>
<p>Finally, I want to provide two quotes from the book I liked and that describe the book well. They&#8217;re in Spanish, and I don&#8217;t have enough literary pizzazz to translate them to English in a convincing way.</p>
<p>From the conversation of Aureliano Babilonia with Pillar Ternera close to the end:</p>
<blockquote><p>
No había ningún misterio en el corazón de un Buendía que fuera impenetrable para ella, porque un siglo de naipes y de experiencias le había enseñado que la historia de la familia era un engranaje de repeticiones irreparables, una rueda giratoria que hubiera seguido dando vueltas hasta la eternidad, de no haber sido por el desgaste progresivo e irremediable del eje.
</p></blockquote>
<p>And the last sentence in the book:</p>
<blockquote><p>Sin embargo, antes de llegar al verso final, ya había comprendido que no saldría jamás de ese cuarto, pues estaba previsto que la ciudad de los espejos (o espejismos) sería arrasada por el viento y desterrada de la memoria de los hombres, en el instante en que Aureliano Babilonia acabara de decifrar los pergaminos, y que todo lo escrito en ellos era irrepetible desde siempre y para siempre, porque los estirpes condenados a cien años de soledad no tenían una segunda oportunidad sobre la tierra.</p></blockquote>
<p>I&#8217;m asking myself if I like the book. I don&#8217;t have the answer. There are things about it I really dislike, and some things I like beyond my own understanding. After reading it once, I took it up again, and can&#8217;t be sure that I won&#8217;t read it once again sometime in the future. It&#8217;s still a mystery for me.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/09/book-review-cien-anos-de-soledad-by-gabriel-garcia-marquez/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Python impressions</title>
		<link>http://eli.thegreenplace.net/2008/06/06/python-impressions/</link>
		<comments>http://eli.thegreenplace.net/2008/06/06/python-impressions/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 08:42:42 +0000</pubDate>
		<dc:creator>eliben</dc:creator>
		
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://eli.thegreenplace.net/2008/06/06/python-impressions/</guid>
		<description><![CDATA[Introduction
Update: A few words on my programming background. I&#8217;m most proficient in C and Perl, with C++ coming closely behind. Additionally, I&#8217;ve programmed in Ruby, Lisp, Scheme, Matlab and Ada. More on this here and here.

About 3 weeks ago, I&#8217;ve decided to give Python a try. During this time I have been intensively learning and [...]]]></description>
			<content:encoded><![CDATA[<h3>Introduction</h3>
<p><em><strong>Update:</strong> A few words on my programming background. I&#8217;m most proficient in C and Perl, with C++ coming closely behind. Additionally, I&#8217;ve programmed in Ruby, Lisp, Scheme, Matlab and Ada. More on this <a href="http://eli.thegreenplace.net/2006/08/11/my-current-programming-language-arsenal/">here</a> and <a href="http://eli.thegreenplace.net/2008/02/01/a-subjective-comparison-between-perl-and-ruby/">here</a>.</em>
</p>
<p>About 3 weeks ago, I&#8217;ve decided to give Python a try. During this time I have been intensively learning and using Python, so now I&#8217;m ready to give a list of my initial impressions.</p>
<p>First, a word on my learning process. Python is a mature and useful language, so from the start I decided not only to play around, but to take it quite seriously. So, apart from reading the official <a href="http://docs.python.org/tut/">Python tutorial</a> and most of the free online book <a href="http://www.diveintopython.org/">Dive into Python</a> I spent a lot of time actually using Python, both for writing test scripts that display various features I might need and useful programs, both at work and home. Here&#8217;s a rough list of the code I&#8217;ve written to get familiar with Python, in no particular order:</p>
<ul>
<li>Accessing Windows DLLs from Python code</li>
<li>GUIs with wxPython</li>
<li>Tools for working with files, paths and directories</li>
<li>Code involving threads and sockets</li>
<li>Various scripts to test how Python finds its modules and packages</li>
<li>Used py2exe to package scripts as self-contained .exe files</li>
</ul>
<p>I&#8217;ve also written a couple of non-toy applications that actually do something useful:</p>
<ul>
<li><a href="http://eli.thegreenplace.net/2008/05/31/a-tetris-clone-in-python-wxpython/">wxPyTris</a> &#8211; a Tetris clone</li>
<li>A simple <span class="caps">GUI</span> that can work as a <span class="caps">XML</span>-RPC client or (threaded) server</li>
<li>A netlist / pinlist comparison utility useful for my work. I had it previously written in Perl, but now I&#8217;ve written a more feature-complete version in Python with a wxPython <span class="caps">GUI</span></li>
</ul>
<p>In total, I think I&#8217;ve written at least 3K lines of Python code and read a lot of documentation, newsgroup posts and tutorials. I&#8217;m still far from being proficient in Python, but I can now use it quite effectively.</p>
<h3>My Python impressions</h3>
<p>The impressions are divided to positive and negative, and inside each section there&#8217;s no particular order.</p>
<h4>What I like about Python</h4>
<ul>
<li>Significant indentation is actually a pretty good thing. Since I always pedantically indent my code anyway, I don&#8217;t find it to be an   impediment. On the contrary &#8211; it has some very desirable features: much less punctuation to type (braces, begin/end, etc.), and code written by others is usually easier to understand, because Python forces it to be structurally cleaner.</li>
<li>In a way, Python is openly supported by a large company that uses it extensively &#8211; Google. This means that there are a few smart people who get paid to develop and improve Python. For example <a href="http://www.python.org/~guido/">Guido Von Rossum</a>, the Python creator, works on Python in Google. I heard that the &#8220;release manager&#8221; for Python 2.6 also works for Google. This is important: while enthusiasts can create great tools in their free time, my experience tells me that to really perfect a tool, consistently, it is important for some people to earn their living from working on it.</li>
<li>The Python community doesn&#8217;t treat Windows as a Nth-priority platform. All modules I&#8217;ve seen so far come with easy installers for Windows that <em>just work</em>. This is very important for me, as 95% of my work is being done on Windows.</li>
<li>The documentation is very good</li>
<li><a href="http://www.wxpython.org/py.php">PyCrust</a> is a very helpful tool</li>
<li>wxPython &#8211; very mature and easy to use. The wxPython demo is amazing. Everything works very quickly, with beautiful native GUIs. wxPython is so good that most open-source Python IDEs seem to be written in pure Python + wxPython</li>
<li>Convenient built-in named arguments</li>
<li>Docstrings</li>
<li>The <code>in</code> operator</li>
<li>List comprehensions </li>
<li>Chained comparisons in expressions: <code>(1 &lt; x &lt; 4)</code> instead of <code>(x &gt; 1 and x &lt; 4)</code>. Remember that this feature really shines when you replace <code>x</code> by <code>self.server.count_connections()</code> <img src='http://eli.thegreenplace.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li>Batteries included &#8211; the Python standard library has a lot in it, and this is a very good thing, especially when you want to quickly distribute your scripts to coworkers who have no idea about Python.</li>
<li>The way the <code>print</code> function works is quite convenient &#8211; it adds spaces between its arguments and a newline at the end, and thus saves boilerplate typing when debugging. And let&#8217;s face it, <code>print</code> in Python is used mainly for debugging anyway (files are written with the <code>write()</code> method of file objects). </li>
<li>Python has native threads !! Although some restrictions on multi-CPU concurrency are imposed by the <a href="http://docs.python.org/api/threads.html"><span class="caps">GIL</span></a>, I understand that this can be solved in most cases. A nice feature of native threads is that waiting for a system call in one thread doesn&#8217;t block the other threads (which happens with Ruby&#8217;s green threads).</li>
<li>Excellent support for loading C/C++ DLLs. The standard <code>ctypes</code> module is very convenient and easy to use.</li>
</ul>
<h4>What I don&#8217;t like about Python</h4>
<ul>
<li>Python doesn&#8217;t have a large index of modules like Perl&#8217;s <span class="caps">CPAN</span>. There&#8217;s <a href="www.python.org/pypi">PyPi</a>, but it appears to be both less complete and less universally used than <span class="caps">CPAN</span>.</li>
<li><code>len()</code> is a function and not a method of string. In general, Python is less consistent in this respect than, say, Ruby. Some operations are functions (<code>len</code>, <code>dir</code>), some built-in statements (<code>del</code>) and some object methods (<code>reverse</code>, <code>append</code>, etc.)</li>
<li><code>string</code>&#8217;s <code>join</code> method is OK, but why not also add a <code>join</code> method to a list. It is more elegant to write <code>[1, 2, 3].join(',')</code> than to write <code>', '.join[1, 2, 3]</code></li>
<li>The syntax for a single-item tuple is a parsing-imposed ugliness, akin to the need to separate the closing &#8216;&gt;&#8217;s in C++ nested templates.</li>
<li>Lack of the ability to use ? and ! in identifiers. I came to like the Ruby way of naming predicates and destructive functions, and with Python I&#8217;m back to the C++/Perl dilemmas of <code>isEmpty</code> vs. <code>empty</code> vs. <code>emptyp</code>, etc. instead of the elegant <code>empty?</code></li>
<li>The <code>unless</code> keyword is sorely missing</li>
<li>&#8220;Batteries included&#8221; also has a downside &#8211; there are a lot of clutter and deprecated libraries. While it&#8217;s good for keeping backwards compatibility, for new users this is a bit inconvenient, because you&#8217;re not always sure what to use.</li>
<li>I&#8217;m not particularly fond of the way private methods are called in Python. while I don&#8217;t have a particular problem with methods receiving <code>self</code> and having to use it explicitly (it allows for some surprising flexibility, especially when passing around methods as callable objects), the syntax for private methods is too much on the fingers. Suppose your class has a private method called Foo. In C++, you&#8217;d call <code>Foo()</code> from another method in this class. In Python, you have to bang <code>self.__Foo()</code>. A bit too much. And while we&#8217;re at it, I don&#8217;t like those double underscor</li>
</ul>
<h4>Conclusion</h4>
<p>All considered, I really like Python. The cons are mainly nits that are easy to overcome, while the pros are significant. I&#8217;ll continue practicing Python, and will write a more organized review later on.</p>
]]></content:encoded>
			<wfw:commentRss>http://eli.thegreenplace.net/2008/06/06/python-impressions/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
