<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Mustafa Ulu &#187; Python</title>
	<atom:link href="http://mustafaulu.net/tag/python/feed/" rel="self" type="application/rss+xml" />
	<link>http://mustafaulu.net</link>
	<description>Kişisel günlüğüm</description>
	<lastBuildDate>Thu, 19 Apr 2012 07:15:35 +0000</lastBuildDate>
	<language>tr</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mustafaulu.net' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mustafa Ulu &#187; Python</title>
		<link>http://mustafaulu.net</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mustafaulu.net/osd.xml" title="Mustafa Ulu" />
	<atom:link rel='hub' href='http://mustafaulu.net/?pushpress=hub'/>
		<item>
		<title>Okuma ödevi: İmla denetleyicisi nasıl yazılır?</title>
		<link>http://mustafaulu.net/2007/04/15/okuma-odevi-imla-denetleyicisi-nasil-yazilir/</link>
		<comments>http://mustafaulu.net/2007/04/15/okuma-odevi-imla-denetleyicisi-nasil-yazilir/#comments</comments>
		<pubDate>Sun, 15 Apr 2007 02:23:27 +0000</pubDate>
		<dc:creator>mustafa ulu</dc:creator>
				<category><![CDATA[Okuma ödevi]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://gunluk.mustafau.com/2007/04/15/okuma-odevi-imla-denetleyicisi-nasil-yazilir/</guid>
		<description><![CDATA[Google Okuyucu&#8217;da yazılar arasında zıplarken* birden Peter Norvig ismini görünce heyecanlandım. Kendisi okurken bol bol sövdüğüm &#8220;Yapay Zeka&#8221; kitabının yazarı. Bu makalesinde verimli çalışan bir imla denetleyicisini 21 satırlık Python 2.5 kodu ile nasıl geliştirdiğini anlatıyor. Okuma ödevlerimin arasına ekledim. Türkçeye çevirmek nasip olur mu? Hiç sanmıyorum.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mustafaulu.net&#038;blog=537600&#038;post=76&#038;subd=mustafau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://mustafau.files.wordpress.com/2007/04/how-to-write-a-spelling-corrector.jpg?w=500" alt="how-to-write-a-spelling-corrector.jpg" /></p>
<p>Google Okuyucu&#8217;da yazılar arasında zıplarken<a href="http://gunluk.mustafau.com/" title="j tuşu ile">*</a> birden <a href="http://norvig.com/">Peter Norvig</a> ismini görünce heyecanlandım. Kendisi okurken bol bol sövdüğüm &#8220;<a href="http://aima.cs.berkeley.edu/">Yapay Zeka</a>&#8221; kitabının yazarı.</p>
<p><a href="http://norvig.com/spell-correct.html">Bu makalesinde</a> verimli çalışan bir imla denetleyicisini 21 satırlık <a href="http://python.org/">Python 2.5</a> kodu ile nasıl geliştirdiğini anlatıyor.</p>
<p>Okuma ödevlerimin arasına ekledim. Türkçeye çevirmek nasip olur mu? Hiç sanmıyorum.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mustafau.wordpress.com/76/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mustafau.wordpress.com/76/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mustafau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mustafau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mustafau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mustafau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mustafau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mustafau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mustafau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mustafau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mustafau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mustafau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mustafau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mustafau.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mustafau.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mustafau.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mustafaulu.net&#038;blog=537600&#038;post=76&#038;subd=mustafau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mustafaulu.net/2007/04/15/okuma-odevi-imla-denetleyicisi-nasil-yazilir/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8f6d5acdf6beca511ac2003434abd4c5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mustafa ulu</media:title>
		</media:content>

		<media:content url="http://mustafau.files.wordpress.com/2007/04/how-to-write-a-spelling-corrector.jpg" medium="image">
			<media:title type="html">how-to-write-a-spelling-corrector.jpg</media:title>
		</media:content>
	</item>
		<item>
		<title>TotT: Better Stubbing in Python / Tuvalet Duvarında Test</title>
		<link>http://mustafaulu.net/2007/03/06/tott-better-stubbing-in-python-tuvalet-duvarinda-test/</link>
		<comments>http://mustafaulu.net/2007/03/06/tott-better-stubbing-in-python-tuvalet-duvarinda-test/#comments</comments>
		<pubDate>Tue, 06 Mar 2007 13:45:56 +0000</pubDate>
		<dc:creator>mustafa ulu</dc:creator>
				<category><![CDATA[Yazılım]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://mustafau.wordpress.com/2007/03/06/tott-better-stubbing-in-python-tuvalet-duvarinda-test/</guid>
		<description><![CDATA[Ben Python&#8217;la çalışmaya başladığım sıralarda Google &#8220;Google Testing Blog&#8220;u yayımladı. İlk yazıları ile birlikte yayımladıkları belgeyi hemen indirdim ve incelemeye başladım. Ne yazık ki o zaman Python hakkında yeterli tecrübeye sahip olmadığım için belgede anlatılmak istenen meseleyi anlayamamıştım. Zaman zaman belgeyi tekrar okuyup anlamaya çalışıyordum. En sonunda bugün (28 Ocak 2007) meseleyi tam olarak kavrayabildim. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mustafaulu.net&#038;blog=537600&#038;post=64&#038;subd=mustafau&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://mustafau.files.wordpress.com/2007/03/debugging_vs_testing.kucukresim.PNG?w=500" alt="debugging_vs_testing.PNG" /></p>
<p>Ben Python&#8217;la çalışmaya başladığım sıralarda Google &#8220;<a href="http://googletesting.blogspot.com/">Google Testing Blog</a>&#8220;u yayımladı. İlk yazıları ile birlikte yayımladıkları <a href="http://code.google.com/testing/TotT-2007-01-22.pdf">belgeyi</a> hemen indirdim ve incelemeye başladım. Ne yazık ki o zaman Python hakkında yeterli tecrübeye sahip olmadığım için belgede anlatılmak istenen meseleyi anlayamamıştım. Zaman zaman belgeyi tekrar okuyup anlamaya çalışıyordum. En sonunda bugün (28 Ocak 2007) meseleyi tam olarak kavrayabildim.</p>
<p>Belgede anlatılanları ayrıntılı olarak açıklamaya çalışayım:</p>
<p>Elimizde aşağıdaki gibi bir fonksiyon bulunduğunu varsayalım.</p>
<p><pre class="brush: python;">
def Foo(path):
  if os.path.exists(path):
    return DoSomething()
  else:
    return DoSomethingElse()
</pre></p>
<p>Bu fonksiyon dosya sistemimizdeki herhangi bir adresi parametre olarak alıyor. Bu adresin geçerli bir dosyaya işaret edip etmediğini kontrol ediyor. Sonuçta dosya mevcut ise &#8220;DoSomething()&#8221; değilse &#8220;DoSomethingElse()&#8221; fonksiyonunu çalıştırıyor.</p>
<p>Şimdi unit test sınıfımızın içerisinde bu fonksiyonu test eden bir fonksiyon yazacağız. Yapmak istediğimiz adresteki dosyanın var olması ve olmaması durumlarında yukarıdaki fonksiyonun davranışlarını test etmek.</p>
<p><pre class="brush: python;">
def testFoo(self): # Somewhere in your unit test class / Unit test sınıfının içinde biryerde
  old_exists = os.path.exists
  try:
    os.path.exists = lambda x: True
    self.assertEqual(Foo('bar'), something)
    os.path.exists = lambda x: False
    self.assertEqual(Foo('bar'), something_else)
  finally:
    os.path.exists = old_exists # Remember to clean-up after yourself! / İşinizi bitirdikten sonra ortamı temizlemeyi unutmayın!</pre></p>
<p>Bu fonksiyon ile bütün olasılıkları test ediyoruz. Fakat bazı durumlarda testlerin sonucu beklediğimiz gibi olmuyor. Örneğin “DoSomethingElse()” fonksiyonu başka bir dosyanın varlığını kontrol ediyor olabilir.</p>
<p><pre class="brush: python;">
def DoSomethingElse():
  assert os.path.exists(some_other_file)
  return some_other_file
</pre></p>
<p>Sonuç olumsuz olacaktır çünkü “os.path.exists(path)”in hangi sonucu döndüreceğine test sırasında biz karar veriyoruz. Bu sorunu gidermek için birinci “os.path.exist” yapısını parametre olarak atayabiliriz.</p>
<p><pre class="brush: python;">
def Foo(path, path_checker=os.path.exists):
  if path_checker(path):
    return DoSomething()
  else:
    return DoSomethingElse()
</pre></p>
<p>Böylece sadece yukarıda anlatılan problemi gidermiş olmuyoruz, aynı zamanda hız kazanıyoruz çünkü Python yerel değişkenlere daha hızlı ulaşabiliyor. Test fonksiyonumuz da aşağıdaki gibi kısaltılabiliyor.</p>
<p><pre class="brush: python;">
def testFoo(self):
  self.assertEqual(Foo('bar', lambda x: True), something)
  self.assertEqual(Foo('bar', lambda x: False), something_else)
</pre></p>
<p>Debugging socks. Testing rocks. / Böcek avını bırak. Test etmeye bak.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mustafau.wordpress.com/64/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mustafau.wordpress.com/64/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mustafau.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mustafau.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mustafau.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mustafau.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mustafau.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mustafau.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mustafau.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mustafau.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mustafau.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mustafau.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mustafau.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mustafau.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mustafau.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mustafau.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mustafaulu.net&#038;blog=537600&#038;post=64&#038;subd=mustafau&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mustafaulu.net/2007/03/06/tott-better-stubbing-in-python-tuvalet-duvarinda-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/8f6d5acdf6beca511ac2003434abd4c5?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">mustafa ulu</media:title>
		</media:content>

		<media:content url="http://mustafau.files.wordpress.com/2007/03/debugging_vs_testing.kucukresim.PNG" medium="image">
			<media:title type="html">debugging_vs_testing.PNG</media:title>
		</media:content>
	</item>
	</channel>
</rss>
