<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:georss="http://www.georss.org/georss" xmlns:gml="http://www.opengis.net/gml"
>

<channel>
	<title>Developer with some grey hairs &#187; python</title>
	<atom:link href="http://kai.system7.de/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://kai.system7.de</link>
	<description></description>
	<pubDate>Fri, 21 Jan 2011 12:24:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Python Reinteract</title>
		<link>http://kai.system7.de/2009/04/07/python-reinteract/</link>
		<comments>http://kai.system7.de/2009/04/07/python-reinteract/#comments</comments>
		<pubDate>Tue, 07 Apr 2009 08:22:41 +0000</pubDate>
		<dc:creator>kai</dc:creator>
		
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://kai.system7.de/?p=438</guid>
		<description><![CDATA[Wer schon mal mit einem Lisp oder Scheme System programmiert hat wird in heutigen &#8220;modernen&#8221; IDE&#8217;s das einfache AusfÃ¼hren von Codeblocks vermissen. Zum Beispiel ist es in EMACS mÃ¶glich einen Code Block mit CTRL-X -CTRL-E auszufÃ¼hren.



Um ein Ã¤hnliches Konzept das etwa an die Shell von Mathematica erinnert, bemÃ¼hte sich Owens Taylor von Red Hat mit [...]]]></description>
			<content:encoded><![CDATA[<p>Wer schon mal mit einem Lisp oder Scheme System programmiert hat wird in heutigen &#8220;modernen&#8221; <a href="http://de.wikipedia.org/wiki/Integrierte_Entwicklungsumgebung">IDE&#8217;s</a> das einfache AusfÃ¼hren von Codeblocks vermissen. Zum Beispiel ist es in <a href="http://de.wikipedia.org/wiki/Emacs">EMACS</a> mÃ¶glich einen Code Block mit CTRL-X -CTRL-E auszufÃ¼hren.</p>
<p><center><br />
<img src="http://kai.system7.de/images/emacs-lispmode.jpg" alt="emacs lisp-mode" /><br />
</center></p>
<p>Um ein Ã¤hnliches Konzept das etwa an die Shell von <a href="http://de.wikipedia.org/wiki/Mathematica">Mathematica</a> erinnert, bemÃ¼hte sich <a href="http://blog.fishsoup.net/">Owens Taylor</a> von <a href="http://www.redhat.com/">Red Hat</a> mit seinem Reinteract. Reinteract steht seit dem 26. MÃ¤rz in der Version 0.5.0 zu VerfÃ¼gung. Versionen fÃ¼r Linux, Windows und OS X stehen zum download bereit. </p>
<p>Owen kam auf eine geniale Idee. Schaut euch mal folgenden kleinen Screenshot an. </p>
<p><center><br />
<img src="http://kai.system7.de/images/reinteract1.jpg" alt="reinteract" /><br />
</center></p>
<p>Nach der Eingabe von &#8220;a=[1,2]&#8221; und &#8220;print(a)&#8221; hab ich einfach CTRL-RETURN gedrÃ¼ckt. Sofort erscheint die die LÃ¶sung des kleinen 2 Zeilers unter der &#8220;print(a)&#8221; Zeile. Ã„ndern wir nun die obere Zeile in &#8220;a=[1,2,3]&#8221;  und drÃ¼cken wieder CTRL-RETURN steht unter der &#8220;print(a)&#8221; Zeile sofort &#8220;[1,2,3]&#8220;. Dass solch eine Programmierhilfe fÃ¼r PythonanfÃ¤nger extrem hilfreich ist, muss man nicht diskutieren . Aber Reinteract kann natÃ¼rlich noch viel mehr und dient auch den geÃ¼bten Python Entwickler im Experimentieren. Zum Beispiel hab ich Letztens etwas mehr mit dem Namespace <a href="http://docs.python.org/library/itertools.html">itertools</a> von Python gespielt.<br />
<center><br />
<img src="http://kai.system7.de/images/reinteract2.jpg" alt="reinteract" /><br />
</center></p>
<p>Reinteract kann zusÃ¤tzlich noch CodeCompletion und zeigt die __docs__ Hilfe an, wenn die Maus Ã¼ber einen Type oder einer Methode verweilt. In Verbindung mit <a href="http://numpy.scipy.org/">numpy</a> kann Reinteract sogar die Plot Ausgaben in dem Worksheet anzeigen. </p>
<p>Reinteract ist ein schÃ¶ner Schritt fÃ¼r <a href="http://www.python.org/">Python</a> und man kann erwarten, das dieses Tool bald ein kleines Standardwerkzeug fÃ¼r Pythonentwickler wird. </p>
<p>Links:</p>
<ul>
<li>Talk from Owen Taylor about Reinteract at PyCon 2009 <a href="http://blip.tv/file/1957215">Link</a></li>
<li>Home from Reinteract <a href="http://www.reinteract.org/trac/">Link</a></li
</ul>
]]></content:encoded>
			<wfw:commentRss>http://kai.system7.de/2009/04/07/python-reinteract/feed/</wfw:commentRss>
		</item>
		<item>
		<title>PyRoom das WriterRoom fÃ¼r Linux</title>
		<link>http://kai.system7.de/2008/12/09/pyroom-das-writerroom-fur-linux/</link>
		<comments>http://kai.system7.de/2008/12/09/pyroom-das-writerroom-fur-linux/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 18:06:23 +0000</pubDate>
		<dc:creator>kai</dc:creator>
		
		<category><![CDATA[linux]]></category>

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

		<guid isPermaLink="false">http://kai.system7.de/?p=171</guid>
		<description><![CDATA[Mit PyRoom hat nun auch endlich ein Editor ala WriterRoom es auf den Linux Desktop geschafft. PyRoom wird wie der Name schon vermuten lÃ¤sst in Python entwickelt. Die aktuelle Version 0.3.2 ist bei weitem noch nicht das Ende der Entwicklung von PyRoom. Als erstes fÃ¤llt der etwas zu kleine Font auf. Auch wird etwas wenig [...]]]></description>
			<content:encoded><![CDATA[<p>Mit <a href="http://pyroom.org/">PyRoom</a> hat nun auch endlich ein Editor ala <a href="http://www.hogbaysoftware.com/products/writeroom">WriterRoom</a> es auf den Linux Desktop geschafft. PyRoom wird wie der Name schon vermuten lÃ¤sst in Python entwickelt. Die aktuelle Version 0.3.2 ist bei weitem noch nicht das Ende der Entwicklung von PyRoom. Als erstes fÃ¤llt der etwas zu kleine Font auf. Auch wird etwas wenig Platz vom Bildschirm verwendet. Warum zum Beispiel nicht die TextflÃ¤che Ã¼ber die gesamte HÃ¶he des Bildschirm geht ist schon etwas blÃ¶d. Aber kurz nachdem ich mich darÃ¼ber geÃ¤rgert habe, habe ich schon den Konfigurationsdialog ( CTRL-P ) gefunden und gleich die TextflÃ¤che und den Font vergrÃ¶ÃŸert. Das geht fantastisch einfach und man sieht hinter dem Konfigurationsdialog gleich die neue Einstellung. Einfach super nun kann ich mich richtig Ã¼ber PyRoom freuen. Absolut hervorragend finde ich die MÃ¶glichkeit Ã¼ber CTRL-PAGEUP und CTRL-PAGEDOWN durch verschiedene Textbuffer zu wandern. Alles was nun noch fehlt ist der Tastaturton wie in Q10. Aber der wird sicherlich noch kommen. </p>
<p>Zum installieren ( Ubuntu 8.10 ) einfach die folgenden beiden Zeilen am Ende in die Datei die /etc/apt/sources.list einfÃ¼gen. </p>
<p><em>deb http://ppa.launchpad.net/pyroom-dev/ubuntu intrepid main</em><br />
<em>deb-src http://ppa.launchpad.net/pyroom-dev/ubuntu intrepid main</em></p>
<p>Danach mit</p>
<p> <em>sudo apt-get update &#038;&#038; sudo apt-get install pyroom</em></p>
<p>Pyromm installieren. Schon findet man Pyroom im AnwendungsmenÃ¼ unter dem BÃ¼ro MenÃ¼punkt. Mit CTRL-H die Hilfe aufrufen und schnell die paar Darstellungsoptionen anpassen und los gehts. </p>
<p>Dieser Text wurde natÃ¼rlich auch mit Pyroom geschrieben. <img src='http://kai.system7.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><a href="http://pyroom.org/img/Screenshot.png">Screenshot</a> und noch ein <a href="http://kai.system7.de/2008/04/13/q10/">Bericht</a> von anderen WriterRoom Clonen.</p>
]]></content:encoded>
			<wfw:commentRss>http://kai.system7.de/2008/12/09/pyroom-das-writerroom-fur-linux/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Hashtable vs. List</title>
		<link>http://kai.system7.de/2008/01/25/hashtable-vs-list/</link>
		<comments>http://kai.system7.de/2008/01/25/hashtable-vs-list/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 16:47:53 +0000</pubDate>
		<dc:creator>kai</dc:creator>
		
		<category><![CDATA[english]]></category>

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

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

		<guid isPermaLink="false">http://kai.system7.de/2008/01/25/hashtable-vs-list/</guid>
		<description><![CDATA[Like every student of computer science, I had a course with the title â€žalgorithm and data structuresâ€œ. That is one of the classic subjects in informatics. You are learn things like linked list, tree&#8217;s and so on. Also different algorithm for searching. Sequential search, binary search and top-down 2-3-4 trees. It is a nice and [...]]]></description>
			<content:encoded><![CDATA[<p>Like every student of computer science, I had a course with the title â€žalgorithm and data structuresâ€œ. That is one of the classic subjects in informatics. You are learn things like linked list, tree&#8217;s and so on. Also different algorithm for searching. Sequential search, binary search and top-down 2-3-4 trees. It is a nice and important subject. Today we have frameworks like Java,.NET,Python and they all have build in data structures like lists and hashtables. With these technics it is quite easy to use a list. Here is a small and nice example in Python:</p>
<div class="hlcode">
<div class="syntax">
<pre><span class="nb">list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">10000</span><span class="p">):</span>
   <span class="n">rand</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="mf">50000</span><span class="p">)</span>
   <span class="k">if</span> <span class="ow">not</span> <span class="n">rand</span> <span class="ow">in</span> <span class="nb">list</span><span class="p">:</span>
      <span class="nb">list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">rand</span><span class="p">)</span>
</pre>
</div>
</div>
<p>Now we have a list with up to 10000 random and unique entries. Very easy to program, but you also see the performance problem. In line 4 is a check for the uniqueness of the possible new entry. To check for existence of an element in a list, the framework runs through all elements of the list.  That is a sequential search, the slowest searching algorithm in this universe. This small example needs 365360 microseconds on my machine. </p>
<p>Now lets try a different version with a dictionary. </p>
<div class="hlcode">
<div class="syntax">
<pre><span class="nb">dict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mf">10000</span><span class="p">):</span>
   <span class="n">rand</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mf">0</span><span class="p">,</span><span class="mf">50000</span><span class="p">)</span>
   <span class="k">if</span> <span class="ow">not</span> <span class="nb">dict</span><span class="o">.</span><span class="n">has_key</span><span class="p">(</span><span class="n">rand</span><span class="p">):</span>
      <span class="nb">dict</span><span class="p">[</span><span class="n">rand</span><span class="p">]</span> <span class="o">=</span> <span class="mf">0</span>
</pre>
</div>
</div>
<p>This example needs only 34908 microseconds. That is 10 times faster than the version with the list. It looks very stupid to program a line like â€œdict[rand] = 0â€?, but this solution now uses a different search algorithm. If you increment the loop up to 20000 entries the different is 83times.  But in the near of 30000 it comes to a point where the insort algorithm of the dict structure needs so long that the speed benefit is over. </p>
<p>I wrote another small program to visualize the effect.<br />
<a href="http://kai.system7.de/hashagainstlist/speedtest.py">See the code</a></p>
<p><img src="http://kai.system7.de/images/hashagainstlist.jpg" alt="Hash Against List" /></p>
<p>I found this problem in a small textminig project. Using dictionarys to search for existence of a word in an document was extremely faster than a list. So sometimes you should think about, when to use a list and when use a dictionary like an list. </p>
]]></content:encoded>
			<wfw:commentRss>http://kai.system7.de/2008/01/25/hashtable-vs-list/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Workaround for pkg-config - ecplise CDT Problem</title>
		<link>http://kai.system7.de/2007/09/22/workaround-for-pkg-config-ecplise-cdt-problem/</link>
		<comments>http://kai.system7.de/2007/09/22/workaround-for-pkg-config-ecplise-cdt-problem/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 19:17:04 +0000</pubDate>
		<dc:creator>kai</dc:creator>
		
		<category><![CDATA[english]]></category>

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

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

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

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

		<guid isPermaLink="false">http://kai.system7.de/2007/09/22/workaround-for-pkg-config-ecplise-cdt-problem/</guid>
		<description><![CDATA[In the last days I started to learn a bit more GTK and GDK development. I like eclipse very much, but the new CDT version 4.0 have still no real feature to use the pkg-config tool from the freedesktop organisation. Thats makes me a bit nervous. In the first two small projects I copied all [...]]]></description>
			<content:encoded><![CDATA[<p>In the last days I started to learn a bit more GTK and GDK development. I like eclipse very much, but the new CDT version 4.0 have still no real feature to use the <a href="http://en.wikipedia.org/wiki/Pkg-config">pkg-config</a> tool from the <a href="http://pkg-config.freedesktop.org/wiki/">freedesktop organisation</a>. Thats makes me a bit nervous. In the first two small projects I copied all the include and lib pathes from the pkg-config output. </p>
<p>Example output:</p>
<p>-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/freetype2 -I/usr/include/libpng12  -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm -lpangocairo-1.0 -lfontconfig -lXext -lXrender -lXinerama -lXi -lXrandr -lXcursor -lXfixes -lpango-1.0 -lcairo -lX11 -lgobject-2.0 -lgmodule-2.0 -ldl -lglib-2.0  </p>
<p>You know, that is not really funny. Some evenings ago I developed a small python script to solve this problem a bit. </p>
<p>The biggest problem is that eclipse creates the important XML node after configuring a extra directory or/and library. After you add for example a directory called &#8220;aaa&#8221; and an library called &#8220;aaa&#8221; you can close eclipse and run the python script. </p>
<p>pkg2eclpise.py -p &lt;path to projectpath&gt; -c &lt;pkg-config params&gt;</p>
<p>e.g.:</p>
<p>pkg2eclipse.py -p FirstGTKWindow/ -c &#8220;gtk-2.0 &#8211;cflags &#8211;libs&#8221;</p>
<p>After running the script, restart eclipse and you see all the directorys and librarys in your manipulated project. You can rerun the script again and again. The script avoid duplicated entrys</p>
<p>Have fun with the great CDT 4.0 and the nice fast code completion feature. </p>
<p><a href="http://kai.system7.de/pkgeclipse/pkgconfig2cdt.zip">pkg2eclipse.py</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kai.system7.de/2007/09/22/workaround-for-pkg-config-ecplise-cdt-problem/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

