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

<channel>
	<title>Pragmatic Programmer Issues - pietrowski.info &#187; python</title>
	<atom:link href="http://pietrowski.info/category/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://pietrowski.info</link>
	<description></description>
	<lastBuildDate>Tue, 27 Jul 2010 07:31:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Decorators by Python</title>
		<link>http://pietrowski.info/2008/06/decorators-by-python/</link>
		<comments>http://pietrowski.info/2008/06/decorators-by-python/#comments</comments>
		<pubDate>Mon, 02 Jun 2008 20:38:27 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://pietrowski.info/decorators-by-python/</guid>
		<description><![CDATA[Lately, I&#8217;m using Django. So I also learn Python. And I found that python is very clean and nice language. As we know Python allows that function can also be a parameter to another function. So code similar to this is ok. def decorator(fun): print fun.__name__ def my_fun(): print &#8220;hello world&#8221; decorator(my_fun) But Python provides [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I&#8217;m using Django. So I also learn Python. And I found that python is very clean and nice language.</p>
<p>As we know Python allows that function can also be a parameter to another function. So code similar to this is ok.</p>
<p class="python-code">def decorator(fun):<br />
print fun.__name__<br />
def my_fun():<br />
print &#8220;hello world&#8221;</p>
<p>decorator(my_fun)
</p>
<p>But Python provides some syntactic sugar so the code above is the same as this code:</p>
<p class="python-code">def decorator(fun):<br />
print fun.__name__<br />
@decorator<br />
def my_fun():<br />
print &#8220;hello world&#8221;
</p>
<p>So why it is so important, because I&#8217;m Java programmer and this allows me in elegant way to use something similar to Aspect. For example I can write cache decorator and apply it to every calculation intensive function.</p>
<p class="python-code">class cache:<br />
def __init__(self, function):<br />
self.function = function<br />
self.cache =  {}<br />
def __call__(self, *args):<br />
try:<br />
return self.cache[args]<br />
except KeyError:<br />
self.cache[args] = self.function(*args)<br />
return self.cache[args]</p>
<p>Now for our propose I use a non optimal fibonacci recursive function.</p>
<p class="python-code">def fib(n):<br />
if n &gt; 1:<br />
return fib( n -1 ) + fib ( n -2 )<br />
return 1</p>
<p>And simply measured that using enough large fibonacci number.</p>
<p class="python-code">from time import gmtime, strftime<br />
print &#8220;started %s&#8221; % strftime(&#8220;%a, %d %b %Y %H:%M:%S&#8221;, gmtime())<br />
print fib(35)<br />
print &#8220;ended %s&#8221; % strftime(&#8220;%a, %d %b %Y %H:%M:%S&#8221;, gmtime())</p>
<p>With and without @cache decorator. The output is</p>
<p>With @cache:</p>
<pre>started Mon, 02 Jun 2008 20:32:41
14930352
ended Mon, 02 Jun 2008 20:32:41</pre>
<p>and without:</p>
<pre>started Mon, 02 Jun 2008 20:33:09
14930352
ended Mon, 02 Jun 2008 20:33:19</pre>
<p>The conclusion is that it is great possibility to use such a class/function as I&#8217;m used to when using aspect with java.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2008/06/decorators-by-python/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django tutorial finished</title>
		<link>http://pietrowski.info/2007/02/django-tutorial-finished/</link>
		<comments>http://pietrowski.info/2007/02/django-tutorial-finished/#comments</comments>
		<pubDate>Thu, 15 Feb 2007 21:25:00 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=14</guid>
		<description><![CDATA[Yep it&#8217;s finished. In my opinion django is worth knowing. It&#8217;s easy as RoR, but you always have control about what&#8217;s going on. You must watch out about python syntax it&#8217;s sometimes not obvious that you have one space extra and code doesn&#8217;t work. Last part of tutorial was about forms it normal, I think. [...]]]></description>
			<content:encoded><![CDATA[<p>Yep it&#8217;s finished.<br />
In my opinion django is worth knowing. It&#8217;s easy as RoR, but you always have control about what&#8217;s going on.</p>
<p>You must <span style="color: #990000; font-weight: bold">watch out</span> about python syntax it&#8217;s sometimes not obvious that you have one space extra and code doesn&#8217;t work.</p>
<p>Last part of tutorial was about forms it normal, I think.</p>
<p>I&#8217;m going sleep now. Today I challenge with performance.</p>
<p>I think I won, becouse I really do so many improvements, but Lucene index is about 1Gb and performance  still don&#8217;t <span class="cald-word">satisfied</span>  me.</p>
<p><span style="color: #006600; font-weight: bold">Tomorrow I&#8217;m going to won this battle</span><span style="font-weight: bold">.</span></p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2007/02/django-tutorial-finished/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django 3rd day</title>
		<link>http://pietrowski.info/2007/02/django-3rd-day/</link>
		<comments>http://pietrowski.info/2007/02/django-3rd-day/#comments</comments>
		<pubDate>Wed, 14 Feb 2007 22:04:00 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=13</guid>
		<description><![CDATA[Now Django has no chance. After admin panel my expectation are very high. But once again I was wrong. Today tutorial 4, I didn&#8217;t achieve tutorial 4 because i play basketball and I&#8217;ve got appointment tomorrow about 7 a.m. OK, URL managing, in my opinion it&#8217;s better than RoR because you have full control about [...]]]></description>
			<content:encoded><![CDATA[<p>Now Django has no chance. After admin panel my expectation are very high.</p>
<p><span style="font-weight: bold; color: #993300; font-size: 130%">But once again I was wrong.</span></p>
<p>Today tutorial 4, I didn&#8217;t achieve tutorial 4 because i play basketball and I&#8217;ve got appointment tomorrow about 7 a.m.</p>
<p>OK, URL managing, in my opinion it&#8217;s better than RoR because you have full control about it. For example<br />
<span style="color: #6600cc; font-size: 85%"><br />
<span style="font-family: courier new">(r&#8217;^polls/(?P&lt;poll_id&gt;\d+)/$&#8217;, &#8216;mysite.polls.views.detail&#8217;),</span></span></p>
<p>Means that django all URL that matches regular expression<br />
<span style="color: #6600cc; font-size: 85%"><br />
<span style="font-family: courier new">r&#8217;^polls/(?P&lt;poll_id&gt;\d+)/$&#8217;</span></span></p>
<p>Sends to module mysite.polls.views and call<span style="color: #990000"> detail()</span> function like<br />
<span style="color: #6600cc; font-size: 85%"><br />
<span style="font-family: courier new">detail(request=&lt;httprequest&gt;, poll_id=&#8217;23&#8242;)</span></span></p>
<p>Next, tutorial shows how to write views, template. Finally it shows us a shortcuts. Yeah the functions from django.shortcuts boosts developing speed.</p>
<p>The last part of tutorial before me, and I&#8217;m thinking about topic of application to write, yet another blog is too easy for django and it&#8217;s admin module. So please suggest me something.</p>
<p>Regards<br />
Pedro</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/django" class="performancingtags" rel="tag">django</a>, <a href="http://technorati.com/tag/python" class="performancingtags" rel="tag">python</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2007/02/django-3rd-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Django admin rulez</title>
		<link>http://pietrowski.info/2007/02/django-admin-rulez/</link>
		<comments>http://pietrowski.info/2007/02/django-admin-rulez/#comments</comments>
		<pubDate>Tue, 13 Feb 2007 23:34:00 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=12</guid>
		<description><![CDATA[Holly dolly After I generate django project there was so little files. All Ruby on Rails script directory is in manege.py, setting in settings.py quit simple. Four files, it amazing. Today I&#8217;ve got some time to look at tutorial2. And I don&#8217;t believe it, just can believe, the django admin application is marvelous. I don&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Holly dolly</p>
<p>After I generate django project there was so little files. All Ruby on Rails<br />
script directory is in manege.py,  setting in settings.py quit simple.<br />
Four files, it amazing.</p>
<p>Today I&#8217;ve got some time to look at <a href="http://www.djangoproject.com/documentation/tutorial2/">tutorial2</a>. And I don&#8217;t believe it, just can believe, the django admin application is marvelous.  I don&#8217;t know what to say, it&#8217;s perfect.  Even RoR ajax_scaffold is nothing special compared to django admin.<br />
I Can&#8217;t even write here what I saw. Definitely everyone should see this. Great Job.</p>
<p>And to be honest this confusion was before I read about templates and css possibilities.</p>
<p>What is certain, I follow tutorial3, and definitely I wrote some application in django. Tomorrow I will fighting with bottlenecks, so I&#8217;m going to rest to be prepared.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/python" class="performancingtags" rel="tag">python</a>, <a href="http://technorati.com/tag/django" class="performancingtags" rel="tag">django</a></p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2007/02/django-admin-rulez/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Django first meeting ;)</title>
		<link>http://pietrowski.info/2007/02/django-first-meeting/</link>
		<comments>http://pietrowski.info/2007/02/django-first-meeting/#comments</comments>
		<pubDate>Sun, 11 Feb 2007 22:43:00 +0000</pubDate>
		<dc:creator>pedro</dc:creator>
				<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://pietrowski.info/?p=11</guid>
		<description><![CDATA[Ok I finished bootstrap meeting. It&#8217;s time to look at django framework. Some years ago I try python, and I think it&#8217;s worth knowing. Let&#8217;s see django. Django requires python 2.3+ so I check my machine. pedro@pedrowaty: ~ -V Python 2.4.4 Bingo. Let&#8217;s follow installation instruction, get django tarball. pedro@pedrowaty: ~ wget http://www.djangoproject.com/download/0.95.1/tarball/ tar xzvf [...]]]></description>
			<content:encoded><![CDATA[<p>Ok I finished <a href="http://bootstrap.pl/">bootstrap </a>meeting. It&#8217;s time to look at <a href="http://www.djangoproject.com/">django framework</a>. Some years ago I try python, and I think it&#8217;s worth knowing. Let&#8217;s see django.</p>
<p>Django requires python 2.3+ so I check my machine.</p>
<p><span style="color: #6600cc">pedro@pedrowaty: ~  -V</span><br />
<span style="color: #6600cc">Python 2.4.4</span></p>
<p>Bingo. Let&#8217;s follow installation instruction, get django tarball.</p>
<p><span style="color: #6600cc">pedro@pedrowaty: ~  wget http://www.djangoproject.com/download/0.95.1/tarball/</span><br />
<span style="color: #6600cc">tar xzvf Django-0.95.1.tar.gz</span><br />
<span style="color: #6600cc">cd Django-0.95.1</span><br />
<span style="color: #6600cc">sudo python setup.py install</span></p>
<p>Also I read that this don&#8217;t work with python 2.5, luckily I’ve got 2.4.4 <img src='http://pietrowski.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Next I followed  <a href="http://www.djangoproject.com/documentation/install/">this instruction</a></p>
<p>I follow <a href="http://www.djangoproject.com/documentation/tutorial1">this tutorial 1</a>  and what can I say? It&#8217;s easy as RoR. So the trip just begin, I couldn&#8217;t do my test app with this framework because of my home-life. But I’m sure the next meeting is coming as quick as possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://pietrowski.info/2007/02/django-first-meeting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
