<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.3" -->
<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>Ikke's blog</title>
	<link>http://eikke.com</link>
	<description>'cause this is what I do</description>
	<pubDate>Sun, 02 Nov 2008 14:16:39 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.3</generator>
	<language>en</language>
			<item>
		<title>Got to love the open source communities&#8230;</title>
		<link>http://eikke.com/got-to-love-the-open-source-communities/</link>
		<comments>http://eikke.com/got-to-love-the-open-source-communities/#comments</comments>
		<pubDate>Sun, 02 Nov 2008 14:16:39 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://eikke.com/got-to-love-the-open-source-communities/</guid>
		<description><![CDATA[Hanging around in #coreboot@irc.freenode.net recently, this just passed by:
15:28  &#60;eikke&#62; is it possible in linux to access partitions in an losetup&#8217;ed raw image?
15:29  &#60;carldani&#62;  eikke: yes, I wrote a kernel patch for that
15:29  &#60;eikke&#62; ah, patch :p i did it using &#8211;offset now, but thats kinda hackish
15:29  &#60;carldani&#62;  eikke: the easiest way is to use [...]]]></description>
			<content:encoded><![CDATA[<p>Hanging around in #coreboot@irc.freenode.net recently, this just passed by:</p>
<p>15:28  &lt;eikke&gt; is it possible in linux to access partitions in an losetup&#8217;ed raw image?<br />
15:29  &lt;carldani&gt;  eikke: yes, I wrote a kernel patch for that<br />
15:29  &lt;eikke&gt; ah, patch :p i did it using &#8211;offset now, but thats kinda hackish<br />
15:29  &lt;carldani&gt;  eikke: the easiest way is to use kpartx<br />
15:29  &lt;carldani&gt;  eikke: that was impossible back then<br />
15:30  &lt;eikke&gt; i see<br />
15:30  &lt;carldani&gt;  eikke: kpartx -a /dev/loop0<br />
15:30  &lt;carldani&gt;  eikke: that will give you /dev/mapper/loop0p1 /dev/mapper/loop0p5 etc<br />
15:30  &lt;eikke&gt; cool<br />
15:30  &lt;carldani&gt;  eikke: are you the eikke responsible for ivman?<br />
15:31  &lt;eikke&gt; a long time ago, yes<br />
15:31  &lt;eikke&gt; dont start the flames please :p<br />
15:31  &lt;carldani&gt;  eikke: thanks! I&#8217;m still using it on my laptop</p>
<p>A helps out B, B helps out A, A writes something useful for B, B wrote something used by A, etc. Got to love the open source movement.</p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Got to love the open source communities&#8230;' to Del.icio.us" alt="Add 'Got to love the open source communities&#8230;' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Got to love the open source communities&#8230;' to digg" alt="Add 'Got to love the open source communities&#8230;' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Got+to+love+the+open+source+communities%26%238230%3B&amp;u=http://eikke.com/got-to-love-the-open-source-communities/" title="Add 'Got to love the open source communities&#8230;' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Got to love the open source communities&#8230;' to FURL" alt="Add 'Got to love the open source communities&#8230;' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Got to love the open source communities&#8230;' to reddit" alt="Add 'Got to love the open source communities&#8230;' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/got-to-love-the-open-source-communities/" title="Add 'Got to love the open source communities&#8230;' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Got to love the open source communities&#8230;' to Technorati" alt="Add 'Got to love the open source communities&#8230;' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/got-to-love-the-open-source-communities/&amp;t=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Got to love the open source communities&#8230;' to Yahoo My Web" alt="Add 'Got to love the open source communities&#8230;' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B&amp;description=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Got to love the open source communities&#8230;' to Ma.gnolia" alt="Add 'Got to love the open source communities&#8230;' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Got to love the open source communities&#8230;' to Stumble Upon" alt="Add 'Got to love the open source communities&#8230;' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Got to love the open source communities&#8230;' to Google Bookmarks" alt="Add 'Got to love the open source communities&#8230;' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B&amp;v=3&amp;blocked=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Got to love the open source communities&#8230;' to Spurl" alt="Add 'Got to love the open source communities&#8230;' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Got to love the open source communities&#8230;' to Blogmarks" alt="Add 'Got to love the open source communities&#8230;' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/got-to-love-the-open-source-communities/&amp;title=Got+to+love+the+open+source+communities%26%238230%3B" title="Add 'Got to love the open source communities&#8230;' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Got to love the open source communities&#8230;' to Co.mments" alt="Add 'Got to love the open source communities&#8230;' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/got-to-love-the-open-source-communities/" title="Add 'Got to love the open source communities&#8230;' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Got to love the open source communities&#8230;' to Bloglines" alt="Add 'Got to love the open source communities&#8230;' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/got-to-love-the-open-source-communities/" title="Add 'Got to love the open source communities&#8230;' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Got to love the open source communities&#8230;' to FaceBook" alt="Add 'Got to love the open source communities&#8230;' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/got-to-love-the-open-source-communities/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Python gotcha</title>
		<link>http://eikke.com/python-gotcha/</link>
		<comments>http://eikke.com/python-gotcha/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 19:35:37 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://eikke.com/python-gotcha/</guid>
		<description><![CDATA[Don&#8217;t ever do this unless it&#8217;s really what you want:
import os

def some_func(fd):
    f = os.fdopen(fd, 'w')
    f.write('abc')

fd = get_some_fd()
some_func(fd)
some_other_func(fd)
Here&#8217;s what goes wrong: when some_func comes to an end, f (which is a file-like objects) goes out of scope, is destructed, which causes fd to be closed. I think this is pretty [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t ever do this unless it&#8217;s really what you want:</p>
<pre>import os

def some_func(fd):
    f = os.fdopen(fd, 'w')
    f.write('abc')

fd = get_some_fd()
some_func(fd)
some_other_func(fd)</pre>
<p>Here&#8217;s what goes wrong: when some_func comes to an end, f (which is a file-like objects) goes out of scope, is destructed, which causes fd to be closed. I think this is pretty weird behavior (an object closing an fd it didn&#8217;t open itself), but well.</p>
<p>Here&#8217;s a better version, for reference:</p>
<pre>def some_func(fd):
    f = os.fdopen(os.dup(fd), 'w')
    #Use f here</pre>
<p>Try this on fd 0/1/2 in an (I)Python shell <img src='http://eikke.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha" title="Add 'Python gotcha' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Python gotcha' to Del.icio.us" alt="Add 'Python gotcha' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha" title="Add 'Python gotcha' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Python gotcha' to digg" alt="Add 'Python gotcha' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Python+gotcha&amp;u=http://eikke.com/python-gotcha/" title="Add 'Python gotcha' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Python gotcha' to FURL" alt="Add 'Python gotcha' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha" title="Add 'Python gotcha' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Python gotcha' to reddit" alt="Add 'Python gotcha' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/python-gotcha/" title="Add 'Python gotcha' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Python gotcha' to Technorati" alt="Add 'Python gotcha' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/python-gotcha/&amp;t=Python+gotcha" title="Add 'Python gotcha' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Python gotcha' to Yahoo My Web" alt="Add 'Python gotcha' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha&amp;description=Python+gotcha" title="Add 'Python gotcha' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Python gotcha' to Ma.gnolia" alt="Add 'Python gotcha' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha" title="Add 'Python gotcha' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Python gotcha' to Stumble Upon" alt="Add 'Python gotcha' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/python-gotcha/&amp;title=Python+gotcha" title="Add 'Python gotcha' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Python gotcha' to Google Bookmarks" alt="Add 'Python gotcha' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha&amp;v=3&amp;blocked=Python+gotcha" title="Add 'Python gotcha' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Python gotcha' to Spurl" alt="Add 'Python gotcha' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha" title="Add 'Python gotcha' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Python gotcha' to Blogmarks" alt="Add 'Python gotcha' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/python-gotcha/&amp;title=Python+gotcha" title="Add 'Python gotcha' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Python gotcha' to Co.mments" alt="Add 'Python gotcha' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/python-gotcha/" title="Add 'Python gotcha' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Python gotcha' to Bloglines" alt="Add 'Python gotcha' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/python-gotcha/" title="Add 'Python gotcha' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Python gotcha' to FaceBook" alt="Add 'Python gotcha' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/python-gotcha/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Scripting your app</title>
		<link>http://eikke.com/scripting-your-app/</link>
		<comments>http://eikke.com/scripting-your-app/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 21:12:28 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Desktop]]></category>

		<category><![CDATA[Development]]></category>

		<category><![CDATA[gnome]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://eikke.com/scripting-your-app/</guid>
		<description><![CDATA[Lots of buzz on adding scripting interfaces to applications on Planet GNOME recently, cool. Looks like Alexander Larsson hacked together a wrapper around SpiderMonkey (the Mozilla Engine) to get JavaScript integrated. Related to the jscore-python thing I blogged about before.
Not sure this is the best way to tackle this cool new opportunity though. JavaScript can [...]]]></description>
			<content:encoded><![CDATA[<p>Lots of buzz on adding scripting interfaces to applications on <a href="http://planet.gnome.org" title="Planet GNOME">Planet GNOME</a> recently, cool. Looks like <a href="http://blogs.gnome.org/alexl" title="Alexander Larsson">Alexander Larsson</a> hacked together a wrapper around SpiderMonkey (the Mozilla Engine) to get JavaScript integrated. Related to the jscore-python thing I blogged about <a href="http://eikke.com/embedding-javascript-in-python/" title="Embedding JavaScript in Python - Ikke's Blog">before</a>.</p>
<p>Not sure this is the best way to tackle this cool new opportunity though. JavaScript can be pretty hard to &#8220;get&#8221; for people not used to it, but more familiar with classical languages (wrt object oriented paradigms). I guess lots of current code contributors are not very familiar with JavaScript, but do have an in-depth knowledge of some other scripting language though (not listing any here, you certainly can name some).</p>
<p>So, wouldn&#8217;t it be nice if the GScript interface would be abstract for the application developer, who should just create a script context, put some objects in it, and launch a script, after which the GScript runtime figures out which interpreter to use for this script, so scripting languages become plugable?</p>
<p>Reminds me a little of my old OPluginManager work <img src='http://eikke.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app" title="Add 'Scripting your app' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Scripting your app' to Del.icio.us" alt="Add 'Scripting your app' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app" title="Add 'Scripting your app' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Scripting your app' to digg" alt="Add 'Scripting your app' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Scripting+your+app&amp;u=http://eikke.com/scripting-your-app/" title="Add 'Scripting your app' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Scripting your app' to FURL" alt="Add 'Scripting your app' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app" title="Add 'Scripting your app' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Scripting your app' to reddit" alt="Add 'Scripting your app' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/scripting-your-app/" title="Add 'Scripting your app' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Scripting your app' to Technorati" alt="Add 'Scripting your app' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/scripting-your-app/&amp;t=Scripting+your+app" title="Add 'Scripting your app' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Scripting your app' to Yahoo My Web" alt="Add 'Scripting your app' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app&amp;description=Scripting+your+app" title="Add 'Scripting your app' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Scripting your app' to Ma.gnolia" alt="Add 'Scripting your app' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app" title="Add 'Scripting your app' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Scripting your app' to Stumble Upon" alt="Add 'Scripting your app' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app" title="Add 'Scripting your app' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Scripting your app' to Google Bookmarks" alt="Add 'Scripting your app' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app&amp;v=3&amp;blocked=Scripting+your+app" title="Add 'Scripting your app' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Scripting your app' to Spurl" alt="Add 'Scripting your app' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app" title="Add 'Scripting your app' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Scripting your app' to Blogmarks" alt="Add 'Scripting your app' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/scripting-your-app/&amp;title=Scripting+your+app" title="Add 'Scripting your app' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Scripting your app' to Co.mments" alt="Add 'Scripting your app' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/scripting-your-app/" title="Add 'Scripting your app' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Scripting your app' to Bloglines" alt="Add 'Scripting your app' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/scripting-your-app/" title="Add 'Scripting your app' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Scripting your app' to FaceBook" alt="Add 'Scripting your app' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/scripting-your-app/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Embedding JavaScript in Python</title>
		<link>http://eikke.com/embedding-javascript-in-python/</link>
		<comments>http://eikke.com/embedding-javascript-in-python/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 23:05:16 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[javascriptcore]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://eikke.com/embedding-javascript-in-python/</guid>
		<description><![CDATA[Reading some posts about embedding languages/runtimes in applications on Planet GNOME reminded me I still had to announce some really quick and incomplete code blob I created some days after last GUADEC edition (which was insanely cool, thanks guys).
It takes WebKit&#8217;s JavaScriptCore and allows you to embed it in some Python program, so you, as [...]]]></description>
			<content:encoded><![CDATA[<p>Reading some posts about embedding languages/runtimes in applications on <a href="http://planet.gnome.org" title="Planet GNOME">Planet GNOME</a> reminded me I still had to announce some really quick and incomplete code blob I created some days after last <a href="http://www.guadec.org" title="GUADEC">GUADEC</a> edition (which was insanely cool, thanks guys).</p>
<p>It takes <a href="http://www.webkit.org" title="WebKit">WebKit</a>&#8217;s JavaScriptCore and allows you to embed it in some <a href="http://www.python.org" title="Python">Python</a> program, so you, as a Python developer, can allow consumers to write plugins using JavaScript. Don&#8217;t ask me whether it&#8217;s useful, maybe it&#8217;s not, but anyway.</p>
<p>There&#8217;s one catch: currently there is no support to expose custom Python objects to the JavaScript runtime: you&#8217;re able to use JavaScript objects and functions etc. from within Python, but not the other way around. I started working on this, but the JSCore API lacked some stuff to be able to implement this cleanly (or I missed a part of it, that&#8217;s possible as well), maybe it has changed by now&#8230; There is transparent translation of JavaScript base types: unicode strings, booleans, null (which becomes None in Python), undefined (which becomes jscore.UNDEFINED) and floats.</p>
<p>I did not work on the code for quite a long time because of too much real-job-work, maybe it no longer compiles, sorry&#8230; Anyway, it&#8217;s available in git <a href="http://git.nicolast.be/?p=python-jscore.git;a=summary" title="python-jscore git">here</a>, patches welcome etc. I guess <a href="http://git.nicolast.be/?p=python-jscore.git;a=blob;f=test/test_object.py;h=1604e4db7bb1e9333bcbed305ec3107921708ab0;hb=HEAD#l261">this</a> is the best sample code around. It&#8217;s using <a href="http://www.cython.org" title="Cython">Cython</a> for compilation (never tried with Pyrex, although this might work as well). If anyone can use it, great, if not, too bad, I did learn Cython doing this <img src='http://eikke.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /></p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Embedding JavaScript in Python' to Del.icio.us" alt="Add 'Embedding JavaScript in Python' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Embedding JavaScript in Python' to digg" alt="Add 'Embedding JavaScript in Python' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Embedding+JavaScript+in+Python&amp;u=http://eikke.com/embedding-javascript-in-python/" title="Add 'Embedding JavaScript in Python' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Embedding JavaScript in Python' to FURL" alt="Add 'Embedding JavaScript in Python' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Embedding JavaScript in Python' to reddit" alt="Add 'Embedding JavaScript in Python' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/embedding-javascript-in-python/" title="Add 'Embedding JavaScript in Python' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Embedding JavaScript in Python' to Technorati" alt="Add 'Embedding JavaScript in Python' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/embedding-javascript-in-python/&amp;t=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Embedding JavaScript in Python' to Yahoo My Web" alt="Add 'Embedding JavaScript in Python' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python&amp;description=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Embedding JavaScript in Python' to Ma.gnolia" alt="Add 'Embedding JavaScript in Python' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Embedding JavaScript in Python' to Stumble Upon" alt="Add 'Embedding JavaScript in Python' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Embedding JavaScript in Python' to Google Bookmarks" alt="Add 'Embedding JavaScript in Python' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python&amp;v=3&amp;blocked=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Embedding JavaScript in Python' to Spurl" alt="Add 'Embedding JavaScript in Python' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Embedding JavaScript in Python' to Blogmarks" alt="Add 'Embedding JavaScript in Python' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/embedding-javascript-in-python/&amp;title=Embedding+JavaScript+in+Python" title="Add 'Embedding JavaScript in Python' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Embedding JavaScript in Python' to Co.mments" alt="Add 'Embedding JavaScript in Python' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/embedding-javascript-in-python/" title="Add 'Embedding JavaScript in Python' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Embedding JavaScript in Python' to Bloglines" alt="Add 'Embedding JavaScript in Python' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/embedding-javascript-in-python/" title="Add 'Embedding JavaScript in Python' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Embedding JavaScript in Python' to FaceBook" alt="Add 'Embedding JavaScript in Python' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/embedding-javascript-in-python/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Free Software startups</title>
		<link>http://eikke.com/free-software-startups/</link>
		<comments>http://eikke.com/free-software-startups/#comments</comments>
		<pubDate>Sat, 12 Jul 2008 13:39:43 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://eikke.com/free-software-startups/</guid>
		<description><![CDATA[At GUADEC last days, fun times. One thing I noticed (again) is the growth of the number of small companies, some of them driven by young guys (like, between 25 and 30) doing some really great stuff with Free Software, combining a steady income, whilst still providing valuable contributions to the community.
I&#8217;d want to write [...]]]></description>
			<content:encoded><![CDATA[<p>At GUADEC last days, fun times. One thing I noticed (again) is the growth of the number of small companies, some of them driven by young guys (like, between 25 and 30) doing some really great stuff with Free Software, combining a steady income, whilst still providing valuable contributions to the community.</p>
<p>I&#8217;d want to write more about this seen, but here&#8217;s a quick idea: how about creating a mailing list for, at one side, these young startups or people interested in starting one, and on the other side people who already got their business running, or already established investors or managers, to discuss issues they encounter, potential business plans, how to get in contact with potential customers, how to combine open communication at one side and dealing with closed environments on the other,&#8230;</p>
<p>This could lower the barrier for people to start working full-time on the projects they love, it&#8217;d add value to Free Software because larger companies can start using it even more, because more expertise and consultancy is available on the market,&#8230;</p>
<p>I guess this is just a shot in the dark, but I think it could be pretty useful. Thoughts?</p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups" title="Add 'Free Software startups' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Free Software startups' to Del.icio.us" alt="Add 'Free Software startups' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups" title="Add 'Free Software startups' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Free Software startups' to digg" alt="Add 'Free Software startups' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Free+Software+startups&amp;u=http://eikke.com/free-software-startups/" title="Add 'Free Software startups' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Free Software startups' to FURL" alt="Add 'Free Software startups' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups" title="Add 'Free Software startups' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Free Software startups' to reddit" alt="Add 'Free Software startups' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/free-software-startups/" title="Add 'Free Software startups' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Free Software startups' to Technorati" alt="Add 'Free Software startups' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/free-software-startups/&amp;t=Free+Software+startups" title="Add 'Free Software startups' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Free Software startups' to Yahoo My Web" alt="Add 'Free Software startups' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups&amp;description=Free+Software+startups" title="Add 'Free Software startups' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Free Software startups' to Ma.gnolia" alt="Add 'Free Software startups' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups" title="Add 'Free Software startups' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Free Software startups' to Stumble Upon" alt="Add 'Free Software startups' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups" title="Add 'Free Software startups' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Free Software startups' to Google Bookmarks" alt="Add 'Free Software startups' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups&amp;v=3&amp;blocked=Free+Software+startups" title="Add 'Free Software startups' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Free Software startups' to Spurl" alt="Add 'Free Software startups' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups" title="Add 'Free Software startups' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Free Software startups' to Blogmarks" alt="Add 'Free Software startups' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/free-software-startups/&amp;title=Free+Software+startups" title="Add 'Free Software startups' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Free Software startups' to Co.mments" alt="Add 'Free Software startups' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/free-software-startups/" title="Add 'Free Software startups' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Free Software startups' to Bloglines" alt="Add 'Free Software startups' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/free-software-startups/" title="Add 'Free Software startups' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Free Software startups' to FaceBook" alt="Add 'Free Software startups' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/free-software-startups/feed/</wfw:commentRss>
		</item>
		<item>
		<title>GUADEC</title>
		<link>http://eikke.com/guadec/</link>
		<comments>http://eikke.com/guadec/#comments</comments>
		<pubDate>Sat, 05 Jul 2008 13:53:37 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Various]]></category>

		<category><![CDATA[gnome]]></category>

		<category><![CDATA[GUADEC]]></category>

		<guid isPermaLink="false">http://eikke.com/guadec/</guid>
		<description><![CDATA[Leaving for GUADEC &#8216;08 with RubenV tomorrow. We&#8217;re staying in the Golden Horn Sultanahmet hotel. Packing starts in a minute, see you around.

]]></description>
			<content:encoded><![CDATA[<p>Leaving for <a href="http://guadec.expectnation.com/public/content/main" title="GUADEC '08">GUADEC &#8216;08</a> with <a href="http://www.savanne.be/" title="savanne.be">RubenV</a> tomorrow. We&#8217;re staying in the <a href="http://www.goldenhornhotel.com/eng/index.php" title="Golden Horn Hotel">Golden Horn Sultanahmet</a> hotel. Packing starts in a minute, see you around.</p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/guadec/&amp;title=GUADEC" title="Add 'GUADEC' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'GUADEC' to Del.icio.us" alt="Add 'GUADEC' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/guadec/&amp;title=GUADEC" title="Add 'GUADEC' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'GUADEC' to digg" alt="Add 'GUADEC' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=GUADEC&amp;u=http://eikke.com/guadec/" title="Add 'GUADEC' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'GUADEC' to FURL" alt="Add 'GUADEC' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/guadec/&amp;title=GUADEC" title="Add 'GUADEC' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'GUADEC' to reddit" alt="Add 'GUADEC' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/guadec/" title="Add 'GUADEC' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'GUADEC' to Technorati" alt="Add 'GUADEC' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/guadec/&amp;t=GUADEC" title="Add 'GUADEC' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'GUADEC' to Yahoo My Web" alt="Add 'GUADEC' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/guadec/&amp;title=GUADEC&amp;description=GUADEC" title="Add 'GUADEC' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'GUADEC' to Ma.gnolia" alt="Add 'GUADEC' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/guadec/&amp;title=GUADEC" title="Add 'GUADEC' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'GUADEC' to Stumble Upon" alt="Add 'GUADEC' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/guadec/&amp;title=GUADEC" title="Add 'GUADEC' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'GUADEC' to Google Bookmarks" alt="Add 'GUADEC' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/guadec/&amp;title=GUADEC&amp;v=3&amp;blocked=GUADEC" title="Add 'GUADEC' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'GUADEC' to Spurl" alt="Add 'GUADEC' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/guadec/&amp;title=GUADEC" title="Add 'GUADEC' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'GUADEC' to Blogmarks" alt="Add 'GUADEC' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/guadec/&amp;title=GUADEC" title="Add 'GUADEC' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'GUADEC' to Co.mments" alt="Add 'GUADEC' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/guadec/" title="Add 'GUADEC' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'GUADEC' to Bloglines" alt="Add 'GUADEC' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/guadec/" title="Add 'GUADEC' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'GUADEC' to FaceBook" alt="Add 'GUADEC' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/guadec/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Python &#8216;all&#8217; odity</title>
		<link>http://eikke.com/python-all-odity/</link>
		<comments>http://eikke.com/python-all-odity/#comments</comments>
		<pubDate>Thu, 01 May 2008 13:57:00 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[performance]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://eikke.com/python-all-odity/</guid>
		<description><![CDATA[[update] Question solved, see bottom of post.
Since Python 2.5 the language got a new built-in method &#8216;all&#8217; (and it&#8217;s nephew &#8216;any&#8217;). I wanted to play around with this a little, combined with generators, so I created a little testcase to test performance.
Here&#8217;s the test-case: take a list L of X random numbers in a given [...]]]></description>
			<content:encoded><![CDATA[<p>[update] Question solved, see bottom of post.</p>
<p>Since Python 2.5 the language got a new built-in method &#8216;all&#8217; (and it&#8217;s nephew &#8216;any&#8217;). I wanted to play around with this a little, combined with generators, so I created a little testcase to test performance.</p>
<p>Here&#8217;s the test-case: take a list L of X random numbers in a given range [A, B], and check whether</p>
<ul>
<li>all elements in L are &gt;= A</li>
<li>all elements in L are &gt;= (A + Z) where Z is a number in [0, (B - A)]</li>
</ul>
<p>The first test should always result True, the second test could result to False.</p>
<p>Here&#8217;s the output of a test-run:</p>
<pre>In [1]: import random, sys

In [2]: a = [random.randint(100, sys.maxint) for i in xrange(2000000)]

In [3]: len(a)
Out[3]: 2000000

In [4]: #Check whether all elements are &gt;= 100 

In [5]: %timeit all(i &gt;= 100 for i in a)
10 loops, best of 3: 515 ms per loop

In [6]: %timeit any(i &lt; 100 for i in a)
10 loops, best of 3: 454 ms per loop

In [7]: def f(l):
   ...:     for i in l:
   ...:         if i &lt; 100:
   ...:             return False
   ...:     return True
   ...: 

In [8]: %timeit f(a)
10 loops, best of 3: 292 ms per loop

In [9]: #Same thing for 100000, since now the list shouldn't be completely iterated

In [10]: %timeit all(i &gt;= 100000 for i in a)
100 loops, best of 3: 4.73 ms per loop

In [11]: %timeit any(i &lt; 100000 for i in a)
100 loops, best of 3: 4.29 ms per loop

In [12]: def g(l):
   ....:     for i in l:
   ....:         if i &lt; 100000:
   ....:             return False
   ....:     return True
   ....: 

In [13]: %timeit g(a)
100 loops, best of 3: 2.82 ms per loop

In [14]: #For reference

In [15]: %timeit False in (i &gt;= 100 for i in a)
10 loops, best of 3: 531 ms per loop

In [16]: %timeit False in (i &gt;= 100000 for i in a)
100 loops, best of 3: 5.03 ms per loop</pre>
<p>It&#8217;s as if &#8216;all&#8217;, &#8216;any&#8217; or &#8216;in&#8217; don&#8217;t break/return when a first occurence of False (or True, obviously) is found. Is this the desired behaviour, and if it is, why? The calculation time difference between using all/any/in or a custom-made function (which is, unlike all etc, not written in C) which breaks whenever it can, is pretty astonishing.</p>
<p>[update] Question solved. It&#8217;s pretty normal the function-based approach performs better, since it combines what &#8216;all&#8217; and the generator provided to &#8216;all&#8217; do, taking away the generator function-call overhead. Damn <img src='http://eikke.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Python &#8216;all&#8217; odity' to Del.icio.us" alt="Add 'Python &#8216;all&#8217; odity' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Python &#8216;all&#8217; odity' to digg" alt="Add 'Python &#8216;all&#8217; odity' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Python+%26%238216%3Ball%26%238217%3B+odity&amp;u=http://eikke.com/python-all-odity/" title="Add 'Python &#8216;all&#8217; odity' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Python &#8216;all&#8217; odity' to FURL" alt="Add 'Python &#8216;all&#8217; odity' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Python &#8216;all&#8217; odity' to reddit" alt="Add 'Python &#8216;all&#8217; odity' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/python-all-odity/" title="Add 'Python &#8216;all&#8217; odity' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Python &#8216;all&#8217; odity' to Technorati" alt="Add 'Python &#8216;all&#8217; odity' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/python-all-odity/&amp;t=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Python &#8216;all&#8217; odity' to Yahoo My Web" alt="Add 'Python &#8216;all&#8217; odity' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity&amp;description=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Python &#8216;all&#8217; odity' to Ma.gnolia" alt="Add 'Python &#8216;all&#8217; odity' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Python &#8216;all&#8217; odity' to Stumble Upon" alt="Add 'Python &#8216;all&#8217; odity' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Python &#8216;all&#8217; odity' to Google Bookmarks" alt="Add 'Python &#8216;all&#8217; odity' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity&amp;v=3&amp;blocked=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Python &#8216;all&#8217; odity' to Spurl" alt="Add 'Python &#8216;all&#8217; odity' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Python &#8216;all&#8217; odity' to Blogmarks" alt="Add 'Python &#8216;all&#8217; odity' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/python-all-odity/&amp;title=Python+%26%238216%3Ball%26%238217%3B+odity" title="Add 'Python &#8216;all&#8217; odity' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Python &#8216;all&#8217; odity' to Co.mments" alt="Add 'Python &#8216;all&#8217; odity' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/python-all-odity/" title="Add 'Python &#8216;all&#8217; odity' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Python &#8216;all&#8217; odity' to Bloglines" alt="Add 'Python &#8216;all&#8217; odity' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/python-all-odity/" title="Add 'Python &#8216;all&#8217; odity' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Python &#8216;all&#8217; odity' to FaceBook" alt="Add 'Python &#8216;all&#8217; odity' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/python-all-odity/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Python if/else in lambda</title>
		<link>http://eikke.com/python-ifelse-in-lambda/</link>
		<comments>http://eikke.com/python-ifelse-in-lambda/#comments</comments>
		<pubDate>Sat, 16 Feb 2008 21:24:43 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[functional programming]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://eikke.com/python-ifelse-in-lambda/</guid>
		<description><![CDATA[Scott, in your &#8220;Functional Python&#8221; introduction you write:
The one limitation that most disappoints me is that Python lacks is a functional way of writing if/else.  Sometimes you just want to do something like this:

lambda x : if_else(x&#62;100, “big number”, “little number”)

(This would return the string “big number” if x was greater than 100, and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://scott.andstuff.org/" title="Scott Moonen">Scott</a>, in your &#8220;<a href="http://scott.andstuff.org/FunctionalPython" title="Scott Moonen: Functional Python">Functional Python</a>&#8221; introduction you write:</p>
<blockquote><p>The one limitation that most disappoints me is that Python lacks is a functional way of writing <tt>if</tt>/<tt>else</tt>.  Sometimes you just want to do something like this:</p>
<blockquote>
<pre>lambda x : if_else(x&gt;100, “big number”, “little number”)</pre>
</blockquote>
<p>(This would return the string “big number” if <em>x</em> was greater than 100, and “little number” otherwise.)  Sometimes I get around this by defining my own <tt>if_else</tt> that I can use in lambda-functions:</p>
<blockquote>
<pre>def if_else(condition, a, b) :
   if condition : return a
   else         : return b</pre>
</blockquote>
</blockquote>
<p>Actually, you don&#8217;t need this helper if_else function at all:</p>
<pre>In [1]: f = lambda x: x &gt; 100 and 'big' or 'small'</pre>
<pre>In [2]: for i in (1, 10, 99, 100, 101, 110):
...:     print i, 'is', f(i)
...:
1 is small
10 is small
99 is small
100 is small
101 is big
110 is big</pre>
<p><a href="http://blogs.gnome.org/jamesh/2008/02/12/python-metaclasses/" title="James Henstridge: Python metaclasses">James</a>, obviously you&#8217;re right&#8230; Stupid me didn&#8217;t think about that. Your version won&#8217;t work when a discriminator isn&#8217;t known at import time. But even then a function taking <tt>*args</tt> and <tt>**kwargs</tt> with a class-like name, returning a correct class instance, would cut the job.</p>
<p>Regarding the module/plugin stuff, I&#8217;d rather use setuptools/pkg_resources <img src='http://eikke.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /></p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Python if/else in lambda' to Del.icio.us" alt="Add 'Python if/else in lambda' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Python if/else in lambda' to digg" alt="Add 'Python if/else in lambda' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Python+if%2Felse+in+lambda&amp;u=http://eikke.com/python-ifelse-in-lambda/" title="Add 'Python if/else in lambda' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Python if/else in lambda' to FURL" alt="Add 'Python if/else in lambda' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Python if/else in lambda' to reddit" alt="Add 'Python if/else in lambda' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/python-ifelse-in-lambda/" title="Add 'Python if/else in lambda' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Python if/else in lambda' to Technorati" alt="Add 'Python if/else in lambda' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/python-ifelse-in-lambda/&amp;t=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Python if/else in lambda' to Yahoo My Web" alt="Add 'Python if/else in lambda' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda&amp;description=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Python if/else in lambda' to Ma.gnolia" alt="Add 'Python if/else in lambda' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Python if/else in lambda' to Stumble Upon" alt="Add 'Python if/else in lambda' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Python if/else in lambda' to Google Bookmarks" alt="Add 'Python if/else in lambda' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda&amp;v=3&amp;blocked=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Python if/else in lambda' to Spurl" alt="Add 'Python if/else in lambda' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Python if/else in lambda' to Blogmarks" alt="Add 'Python if/else in lambda' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/python-ifelse-in-lambda/&amp;title=Python+if%2Felse+in+lambda" title="Add 'Python if/else in lambda' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Python if/else in lambda' to Co.mments" alt="Add 'Python if/else in lambda' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/python-ifelse-in-lambda/" title="Add 'Python if/else in lambda' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Python if/else in lambda' to Bloglines" alt="Add 'Python if/else in lambda' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/python-ifelse-in-lambda/" title="Add 'Python if/else in lambda' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Python if/else in lambda' to FaceBook" alt="Add 'Python if/else in lambda' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/python-ifelse-in-lambda/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Code Review comic</title>
		<link>http://eikke.com/code-review-comic/</link>
		<comments>http://eikke.com/code-review-comic/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 20:43:33 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[comic]]></category>

		<guid isPermaLink="false">http://eikke.com/code-review-comic/</guid>
		<description><![CDATA[
I just love this comic.

]]></description>
			<content:encoded><![CDATA[<p><img src="http://eikke.com/wp-content/uploads/2008/02/wtfm.jpg" alt="OSNews: WTFs per minute" /></p>
<p>I just <em>love</em> this comic.</p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic" title="Add 'Code Review comic' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Code Review comic' to Del.icio.us" alt="Add 'Code Review comic' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic" title="Add 'Code Review comic' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Code Review comic' to digg" alt="Add 'Code Review comic' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Code+Review+comic&amp;u=http://eikke.com/code-review-comic/" title="Add 'Code Review comic' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Code Review comic' to FURL" alt="Add 'Code Review comic' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic" title="Add 'Code Review comic' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Code Review comic' to reddit" alt="Add 'Code Review comic' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/code-review-comic/" title="Add 'Code Review comic' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Code Review comic' to Technorati" alt="Add 'Code Review comic' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/code-review-comic/&amp;t=Code+Review+comic" title="Add 'Code Review comic' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Code Review comic' to Yahoo My Web" alt="Add 'Code Review comic' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic&amp;description=Code+Review+comic" title="Add 'Code Review comic' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Code Review comic' to Ma.gnolia" alt="Add 'Code Review comic' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic" title="Add 'Code Review comic' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Code Review comic' to Stumble Upon" alt="Add 'Code Review comic' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic" title="Add 'Code Review comic' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Code Review comic' to Google Bookmarks" alt="Add 'Code Review comic' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic&amp;v=3&amp;blocked=Code+Review+comic" title="Add 'Code Review comic' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Code Review comic' to Spurl" alt="Add 'Code Review comic' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic" title="Add 'Code Review comic' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Code Review comic' to Blogmarks" alt="Add 'Code Review comic' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/code-review-comic/&amp;title=Code+Review+comic" title="Add 'Code Review comic' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Code Review comic' to Co.mments" alt="Add 'Code Review comic' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/code-review-comic/" title="Add 'Code Review comic' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Code Review comic' to Bloglines" alt="Add 'Code Review comic' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/code-review-comic/" title="Add 'Code Review comic' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Code Review comic' to FaceBook" alt="Add 'Code Review comic' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/code-review-comic/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Python factory-like type instances</title>
		<link>http://eikke.com/python-factory-like-type-instances/</link>
		<comments>http://eikke.com/python-factory-like-type-instances/#comments</comments>
		<pubDate>Mon, 11 Feb 2008 19:31:20 +0000</pubDate>
		<dc:creator>Nicolas</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Technology]]></category>

		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://eikke.com/python-factory-like-type-instances/</guid>
		<description><![CDATA[When designing applications or libraries, sometimes you need to be able to create instances of a certain interface (in a liberal sense) at runtime without knowing at write/compile time which specific implementation (class) you&#8217;ll need to use, as this could depend on runtime variables.
An example of this is an interface providing some functionality which should [...]]]></description>
			<content:encoded><![CDATA[<p>When designing applications or libraries, sometimes you need to be able to create instances of a certain interface (in a liberal sense) at runtime without knowing at write/compile time which specific implementation (class) you&#8217;ll need to use, as this could depend on runtime variables.</p>
<p>An example of this is an interface providing some functionality which should be implemented differently on different platforms, eg Linux and Windows.</p>
<p>There are some standard patterns how to achieve this. One of them is the <a href="http://en.wikipedia.org/wiki/Factory_method_pattern" title="Wikipedia: Factory method pattern">factory pattern</a>, which works somewhat like this <a href="http://www.python.org" title="Python">Python</a> example (let&#8217;s pretend &#8216;PLATFORM&#8217; is &#8216;linux2&#8242; or &#8216;win32&#8242;, ie sys.platform):</p>
<pre>#Pretend we use sys.platform instead of PLATFORM where we use it
PLATFORM = 'linux2'

class FooBase(object):
    def say_foo(self):
        print 'foo'

class PlatformFoo(FooBase):
    def say_platform_foo(self):
        raise NotImplementedError

    @staticmethod
    def get_class():
        #Several ways to get this (dict, introspection, if-tree,...), pick yours
        klass = {
            'linux2': LinuxFoo,
            'win32': WindowsFoo,
        }.get(PLATFORM, None)
        if not klass:
            raise Exception, 'Platform not supported'
        return klass

class WindowsFoo(PlatformFoo):
    def say_platform_foo(self):
        print 'win32 foo'

class LinuxFoo(PlatformFoo):
    def say_platform_foo(self):
        print 'linux foo'

def main():
    foo_class = PlatformFoo.get_class()
    foo = foo_class()
    foo.say_platform_foo()

if __name__ == '__main__':
    main()</pre>
<p>Executing this code will, as expected, write &#8216;linux foo&#8217; to the console. Obviously we could not return the platform-specific class in a PlatformFoo function, but an actual instance, up to you.</p>
<p>Python allows you to handle this situation somewhat nicer though, without introducing any intermediate functions, by using metaclasses.</p>
<p> <a href="http://eikke.com/python-factory-like-type-instances/#more-61" class="more-link">(more&#8230;)</a></p>
<!-- Social Bookmarking Reloaded BEGIN --><div class="social_bookmark"><a class="social_img" href="http://del.icio.us/post?url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Del.icio.us"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/delicious.png" title="Add 'Python factory-like type instances' to Del.icio.us" alt="Add 'Python factory-like type instances' to Del.icio.us" /></a><a class="social_img" href="http://digg.com/submit?phase=2&amp;url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to digg"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/digg.png" title="Add 'Python factory-like type instances' to digg" alt="Add 'Python factory-like type instances' to digg" /></a><a class="social_img" href="http://furl.net/storeIt.jsp?t=Python+factory-like+type+instances&amp;u=http://eikke.com/python-factory-like-type-instances/" title="Add 'Python factory-like type instances' to FURL"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/furl.png" title="Add 'Python factory-like type instances' to FURL" alt="Add 'Python factory-like type instances' to FURL" /></a><a class="social_img" href="http://reddit.com/submit?url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to reddit"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/reddit.png" title="Add 'Python factory-like type instances' to reddit" alt="Add 'Python factory-like type instances' to reddit" /></a><a class="social_img" href="http://www.technorati.com/faves?add=http://eikke.com/python-factory-like-type-instances/" title="Add 'Python factory-like type instances' to Technorati"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/technorati.png" title="Add 'Python factory-like type instances' to Technorati" alt="Add 'Python factory-like type instances' to Technorati" /></a><a class="social_img" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://eikke.com/python-factory-like-type-instances/&amp;t=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Yahoo My Web"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/yahoo_myweb.png" title="Add 'Python factory-like type instances' to Yahoo My Web" alt="Add 'Python factory-like type instances' to Yahoo My Web" /></a><a class="social_img" href="http://ma.gnolia.com/bookmarklet/add?url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances&amp;description=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Ma.gnolia"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/magnolia.png" title="Add 'Python factory-like type instances' to Ma.gnolia" alt="Add 'Python factory-like type instances' to Ma.gnolia" /></a><a class="social_img" href="http://www.stumbleupon.com/submit?url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Stumble Upon"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/stumbleupon.png" title="Add 'Python factory-like type instances' to Stumble Upon" alt="Add 'Python factory-like type instances' to Stumble Upon" /></a><a class="social_img" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Google Bookmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/google.png" title="Add 'Python factory-like type instances' to Google Bookmarks" alt="Add 'Python factory-like type instances' to Google Bookmarks" /></a><a class="social_img" href="http://www.spurl.net/spurl.php?url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances&amp;v=3&amp;blocked=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Spurl"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/spurl.png" title="Add 'Python factory-like type instances' to Spurl" alt="Add 'Python factory-like type instances' to Spurl" /></a><a class="social_img" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Blogmarks"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bmarks.png" title="Add 'Python factory-like type instances' to Blogmarks" alt="Add 'Python factory-like type instances' to Blogmarks" /></a><a class="social_img" href="http://co.mments.com/track?url=http://eikke.com/python-factory-like-type-instances/&amp;title=Python+factory-like+type+instances" title="Add 'Python factory-like type instances' to Co.mments"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/comments.png" title="Add 'Python factory-like type instances' to Co.mments" alt="Add 'Python factory-like type instances' to Co.mments" /></a><a class="social_img" href="http://www.bloglines.com/sub/http://eikke.com/python-factory-like-type-instances/" title="Add 'Python factory-like type instances' to Bloglines"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/bloglines.png" title="Add 'Python factory-like type instances' to Bloglines" alt="Add 'Python factory-like type instances' to Bloglines" /></a><a class="social_img" href="http://www.facebook.com/share.php?u=http://eikke.com/python-factory-like-type-instances/" title="Add 'Python factory-like type instances' to FaceBook"><img src="http://eikke.com/wp-content/plugins/social-bookmarking-reloaded/facebook.png" title="Add 'Python factory-like type instances' to FaceBook" alt="Add 'Python factory-like type instances' to FaceBook" /></a></div>
<!-- Social Bookmarking Reloaded END -->]]></content:encoded>
			<wfw:commentRss>http://eikke.com/python-factory-like-type-instances/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

