<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8777218451156729009</id><updated>2011-07-09T01:29:33.623+09:00</updated><category term='applescript'/><category term='evernote'/><category term='appengine'/><category term='tokyo'/><category term='java'/><category term='python'/><category term='pylint'/><category term='unittest'/><category term='compiler c'/><category term='mac'/><category term='cat'/><category term='django'/><category term='diary'/><category term='safari'/><title type='text'>polyphrase</title><subtitle type='html'>trial and errors</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-6740539104857307610</id><published>2009-12-04T03:01:00.011+09:00</published><updated>2010-10-05T01:29:55.892+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='compiler c'/><title type='text'>Why does my compiler complain "decimal constant is so large"?</title><content type='html'>&lt;p style="border: 3px solid #58A; padding: 10px"&gt;
This article has been moved to &lt;a href="http://www.polyphrase.com/2009/12/04/why-does-my-compiler-complain-decimal-constant-is-so-large.html"&gt;http://www.polyphrase.com/2009/12/04/why-does-my-compiler-complain-decimal-constant-is-so-large.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;
Today my friend tweeted that &lt;em&gt;&amp;quot;Why does my compiler complain about decimal constant is so large for -9223372036854775808?&amp;quot;&lt;/em&gt;. To my shame, I misunderstood what he said at first. I replied to his tweet thus:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;
&amp;quot;It&amp;#39;s overflow!&amp;quot;&lt;/p&gt;
&amp;quot;No. -9223372036854775808 is the minimum value of 64 bit integers.&amp;quot;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;
He replied me back. he&amp;#39;s right.&lt;/p&gt;

&lt;p&gt; The number &lt;tt&gt;-9223372036854775808&lt;/tt&gt; (&lt;tt&gt;-2&lt;sup&gt;63&lt;/sup&gt; -1&lt;/tt&gt;) is the minimum value of 64 bit integers. So why the compiler emitted the warning? it&amp;#39;s broken?&lt;/p&gt;

&lt;p&gt;
&lt;em&gt;Definitely not.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;
In compiler&amp;#39;s internal, the unadorned decimal constant &amp;quot;-9223372036854775808&amp;quot; is splitted into two tokens, an unary minus operator &amp;#39;-&amp;#39; and &amp;#39;9223372036854775808&amp;#39;.&lt;/p&gt;

&lt;p&gt;
The decimal number &lt;tt&gt;9223372036854775808&lt;/tt&gt; is too large, and &lt;strong&gt;its type is interpreted deferently&lt;/strong&gt; depending on which version of ISO C spec (C90 or C99?), or which data models (LP64, LLP64, ...?). So the compiler warned us that &lt;em&gt;&amp;quot;warning: this decimal constant is unsigned only in ISO C90&amp;quot;.&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://gcc.gnu.org/ml/gcc-bugs/2001-10/msg00767.html"&gt;&amp;#39;Neil Booth&amp;#39; - Re: warning: decimal constant is so large that it is unsigned&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://groups.google.com/group/comp.lang.c++/browse_thread/thread/4f5ed69b31fd5e1e?pli=1"&gt;What&amp;#39;s the meaning of this warning: this decimal constant is unsigned only in ISO C90&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-6740539104857307610?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/6740539104857307610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=6740539104857307610' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/6740539104857307610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/6740539104857307610'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2009/12/why-my-compiler-complains-decimal.html' title='Why does my compiler complain &quot;decimal constant is so large&quot;?'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-7257968938706374610</id><published>2009-12-01T01:24:00.003+09:00</published><updated>2009-12-01T02:44:36.018+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='django'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><category scheme='http://www.blogger.com/atom/ns#' term='appengine'/><title type='text'>main.py to use Django 1.1 on Google AppEngine SDK 1.2.7</title><content type='html'>&lt;p&gt;
I tried today to use &lt;a href="http://www.djangoproject.com/"&gt;Django&lt;/a&gt; 1.1 on &lt;a href="http://code.google.com/intl/en/appengine/"&gt;Google AppEngine&lt;/a&gt; SDK 1.2.7. Here is the &lt;tt&gt;main.py&lt;/tt&gt; for this purpose:&lt;/p&gt;

&lt;script src="http://gist.github.com/245523.js?file=main.py"&gt;&lt;/script&gt;

&lt;p&gt;
Thanks to these helpful articles:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://tekpizza.blogspot.com/2009/11/mainpy-for-django-11-in-google-app.html"&gt;main.py for Django 1.1 In Google App Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://code.google.com/intl/en/appengine/articles/django.html"&gt;Running Django on Google App Engine&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://docs.djangoproject.com/en/dev/topics/signals/"&gt;Django | Signals | Django Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-7257968938706374610?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/7257968938706374610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=7257968938706374610' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/7257968938706374610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/7257968938706374610'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2009/12/mainpy-to-use-django-11-on-google.html' title='main.py to use Django 1.1 on Google AppEngine SDK 1.2.7'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-9191594084084096580</id><published>2008-12-15T22:02:00.004+09:00</published><updated>2008-12-15T23:17:37.472+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='evernote'/><category scheme='http://www.blogger.com/atom/ns#' term='safari'/><category scheme='http://www.blogger.com/atom/ns#' term='mac'/><category scheme='http://www.blogger.com/atom/ns#' term='applescript'/><title type='text'>AppleScript: Send link from Safari to Evernote.app</title><content type='html'>&lt;p&gt;
I wrote &lt;a href="http://gist.github.com/33786" title="gist: 33786 — GitHub"&gt;a tiny AppleScript&lt;/a&gt; that helps to work with &lt;a href="http://evernote.com/about/download/#a-macwin" title="Downloads | Evernote Corporation"&gt;Mac OS X version of Evernote&lt;/a&gt; (Evernote.app). With this script, you can easily add link to web page opened in Safari.&lt;/p&gt;

&lt;h4&gt;How To Use&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Launch &lt;strong&gt;Script Editor.app&lt;/strong&gt; (at &lt;tt&gt;/Applications/AppleScript/Script Editor.app&lt;/tt&gt;)&lt;/li&gt;
&lt;li&gt;Just copy the script (below or &lt;a href="http://gist.github.com/raw/33786/13464327188782a5e3c317f1867e475da736e257" title="http://gist.github.com/raw/33786/13464327188782a5e3c317f1867e475da736e257"&gt;here&lt;/a&gt;) from your browser, paste, and run.
&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_p9AemtZLpZI/SUZl-ibpvFI/AAAAAAAAADo/GI2FvDpPIvQ/s1600-h/SaveTheFrog.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_p9AemtZLpZI/SUZl-ibpvFI/AAAAAAAAADo/GI2FvDpPIvQ/s320/SaveTheFrog.jpg" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Now you see a link to an opened web page is added in Evernote.
&lt;br /&gt;&lt;a href="http://4.bp.blogspot.com/_p9AemtZLpZI/SUZl_3NQy-I/AAAAAAAAADw/jrvXI6zHvqI/s1600-h/CopyLinkToEvernote.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://4.bp.blogspot.com/_p9AemtZLpZI/SUZl_3NQy-I/AAAAAAAAADw/jrvXI6zHvqI/s320/CopyLinkToEvernote.jpg" /&gt;&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;The Script&lt;/h4&gt;
&lt;script src="http://gist.github.com/33786.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-9191594084084096580?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/9191594084084096580/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=9191594084084096580' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/9191594084084096580'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/9191594084084096580'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/12/applescript-send-link-from-safari-to.html' title='AppleScript: Send link from Safari to Evernote.app'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_p9AemtZLpZI/SUZl-ibpvFI/AAAAAAAAADo/GI2FvDpPIvQ/s72-c/SaveTheFrog.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-1948270662623593940</id><published>2008-10-15T10:49:00.002+09:00</published><updated>2008-10-15T11:36:31.287+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><title type='text'>Some useful printf-style formats of java.util.Formatter</title><content type='html'>&lt;p&gt;
&lt;tt&gt;&lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Formatter.html" title="Formatter (Java 2 Platform SE 5.0)"&gt;java.util.Formatter&lt;/a&gt;&lt;/tt&gt; which is introduced in J2SE 5.0 provides an interpreter for printf-style format strings. You can use pritf-style format through &lt;tt&gt;&lt;a href="http://java.sun.com/j2se/1.5.0/docs/api/index.html?java/util/Formatter.html" title="PrintStream (Java 2 Platform SE 5.0)"&gt;java.io.PrintStream&lt;/a&gt;&lt;/tt&gt; instance.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;int n = 1000000;
long millis = System.currentTimeMillis();
theLongRunningFunction(n);
System.out.printf(&amp;quot;%d items - %d msecs elapsed\n&amp;quot;,
    n, System.currentTimeMillis() - millis);

&lt;strong&gt;// =&amp;gt; 1000000 items - 164 msecs elapsed&lt;/strong&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
The elapsed seconds is formatted by using &lt;tt&gt;%f&lt;/tt&gt; conversion and precision specifier.
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;int n = 1000000;
long millis = System.currentTimeMillis();
theLongRunningFunction(n);
System.out.printf(&amp;quot;%d items - &lt;strong&gt;%.2f&lt;/strong&gt; secs elapsed\n&amp;quot;,
    n, (System.currentTimeMillis() - millis)/1000.0);

&lt;strong&gt;// =&amp;gt; 1000000 items - 0.16 secs elapsed&lt;/strong&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
The locale-specific grouping separators is also supported.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;int n = 1000000;
long millis = System.currentTimeMillis();
theLongRunningFunction(n);
System.out.printf(&amp;quot;&lt;strong&gt;%,d&lt;/strong&gt; items - %.2f secs elapsed\n&amp;quot;,
    n, (System.currentTimeMillis() - millis)/1000.0);

&lt;strong&gt;// =&amp;gt; 1,000,000 items - 0.16 secs elapsed&lt;/strong&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-1948270662623593940?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/1948270662623593940/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=1948270662623593940' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/1948270662623593940'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/1948270662623593940'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/10/some-useful-printf-style-formats-of.html' title='Some useful printf-style formats of java.util.Formatter'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-2737560926610910391</id><published>2008-09-27T19:15:00.003+09:00</published><updated>2008-09-27T19:44:47.600+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='cat'/><category scheme='http://www.blogger.com/atom/ns#' term='tokyo'/><category scheme='http://www.blogger.com/atom/ns#' term='diary'/><title type='text'>Tokyo Street Cats</title><content type='html'>&lt;p&gt;
Today, I went for a stroll through the streets of Kitano and Kitakarasuyama.&lt;/p&gt;

&lt;iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=q&amp;amp;hl=ja&amp;amp;geocode=&amp;amp;q=%E5%8C%97%E7%83%8F%E5%B1%B1%EF%BC%95%E4%B8%81%E7%9B%AE&amp;amp;sll=35.676341,139.59662&amp;amp;sspn=0.004053,0.009656&amp;amp;ie=UTF8&amp;amp;ll=35.687,139.599066&amp;amp;spn=0.016209,0.038624&amp;amp;z=14&amp;amp;msa=0&amp;amp;msid=106248181240190916372.00043a8a4a413d882d8bd&amp;amp;output=embed&amp;amp;s=AARTsJowcYeToL0nvuPzh7a8XlKbnJoOXg"&gt;&lt;/iframe&gt;&lt;br /&gt;&lt;small&gt;&lt;a href="http://maps.google.com/maps?f=q&amp;amp;hl=ja&amp;amp;geocode=&amp;amp;q=%E5%8C%97%E7%83%8F%E5%B1%B1%EF%BC%95%E4%B8%81%E7%9B%AE&amp;amp;sll=35.676341,139.59662&amp;amp;sspn=0.004053,0.009656&amp;amp;ie=UTF8&amp;amp;ll=35.687,139.599066&amp;amp;spn=0.016209,0.038624&amp;amp;z=14&amp;amp;msa=0&amp;amp;msid=106248181240190916372.00043a8a4a413d882d8bd&amp;amp;source=embed" style="color:#0000FF;text-align:left"&gt;大きな地図で見る&lt;/a&gt;&lt;/small&gt;

&lt;p&gt;
Meeting lots of cats and having happy moments with them.&lt;/p&gt;

&lt;div class="photos"&gt;
&lt;a href="http://www.flickr.com/photos/ishikawa_takanori/2891151035/" title="20080927_0107_1 by Takanori Ishikawa, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3245/2891151035_13492dfb9a_m.jpg" width="240" height="180" alt="20080927_0107_1" /&gt;&lt;/a&gt;
&lt;a href="http://www.flickr.com/photos/ishikawa_takanori/2891151041/" title="20080927_0111_1 by Takanori Ishikawa, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3281/2891151041_cb028fec24_m.jpg" width="240" height="180" alt="20080927_0111_1" /&gt;&lt;/a&gt;
&lt;a href="http://www.flickr.com/photos/ishikawa_takanori/2891151049/" title="20080927_0115_1 by Takanori Ishikawa, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3223/2891151049_273da6edf6_m.jpg" width="240" height="180" alt="20080927_0115_1" /&gt;&lt;/a&gt;
&lt;/div&gt;

&lt;p&gt;
Hide and seek? :-)&lt;/p&gt;
&lt;div class="photos"&gt;
&lt;a href="http://www.flickr.com/photos/ishikawa_takanori/2891151043/" title="20080927_0112_1 by Takanori Ishikawa, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3004/2891151043_b5f27f152e_m.jpg" width="240" height="180" alt="20080927_0112_1" /&gt;&lt;/a&gt;
&lt;a href="http://www.flickr.com/photos/ishikawa_takanori/2891151051/" title="20080927_0118_1 by Takanori Ishikawa, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3027/2891151051_a21f48b509_m.jpg" width="240" height="180" alt="20080927_0118_1" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-2737560926610910391?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/2737560926610910391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=2737560926610910391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/2737560926610910391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/2737560926610910391'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/tokyo-street-cats.html' title='Tokyo Street Cats'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://farm4.static.flickr.com/3245/2891151035_13492dfb9a_t.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-9205698908977896661</id><published>2008-09-26T21:33:00.001+09:00</published><updated>2010-10-05T02:07:33.940+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Python version check</title><content type='html'>&lt;p style="border: 3px solid #58A; padding: 10px"&gt;
This article has been moved to &lt;a href="http://www.polyphrase.com/2008/09/26/python-version-check.html"&gt;http://www.polyphrase.com/2008/09/26/python-version-check.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;
Just use &lt;strong&gt;&lt;tt&gt;sys.hexversion&lt;/tt&gt;&lt;/strong&gt; instead of the string equivalent (&lt;tt&gt;sys.version&lt;/tt&gt;, &lt;tt&gt;sys.version_info&lt;/tt&gt;, ...). It&amp;#39;s flexible and fast.
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; import sys
&amp;gt;&amp;gt;&amp;gt; sys.hexversion
33882608
&amp;gt;&amp;gt;&amp;gt; hex(sys.hexversion)
&amp;#39;0x20501f0&amp;#39;
&amp;gt;&amp;gt;&amp;gt; if sys.hexversion &amp;gt;= 0x2050100:
...   print &amp;quot;Python 2.5.1 or higher&amp;quot;
... 
Python 2.5.1 or higher
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
For example, the &lt;a href="http://docs.python.org/tut/node8.html#SECTION008420000000000000000"&gt;explicit relative imports&lt;/a&gt; is introduced in Python 2.5, you can check this function as:
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;HAS_RELATIVE_IMPORTS = (sys.hexversion &amp;gt;= 0x2050000)&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;tt&gt;sys.hexversion&lt;/tt&gt; is available since 1.5.2. It&amp;#39;s not worth to support older versions.
&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-9205698908977896661?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/9205698908977896661/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=9205698908977896661' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/9205698908977896661'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/9205698908977896661'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/python-version-check.html' title='Python version check'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-4782823635386284706</id><published>2008-09-24T19:34:00.003+09:00</published><updated>2010-10-10T12:46:53.014+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pylint'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>pylint: disable/enable message for a block or statement</title><content type='html'>&lt;p style="border: 3px solid #58A; padding: 10px"&gt;
This article has been moved to &lt;a href="http://www.polyphrase.com/2008/09/24/how-to-disable-pylint-warnings-for-a-block-or-statement.html"&gt;http://www.polyphrase.com/2008/09/24/how-to-disable-pylint-warnings-for-a-block-or-statement.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;
One of my favorite things about &lt;a href="http://www.logilab.org/857"&gt;pylint&lt;/a&gt; is a feature that allows to &lt;strong&gt;disable/enable message for a block or statement&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
For instance, consider the function below:
&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;def scan_code(co, module):
    assert co and module
    if DEBUG: print co.co_filename
    ...
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
The function &lt;tt&gt;scan_code&lt;/tt&gt; has so many debug prints. For performance reason, however, they are &lt;tt&gt;if DEBUG: print&lt;/tt&gt; statements. Now pylint would report so many messages (&lt;strong&gt;&lt;tt&gt;C:&lt;/tt&gt;&lt;/strong&gt; means &lt;em&gt;convention, for programming standard violation&lt;/em&gt;).
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% pylint scan_code
...
C:107:scan_code: More than one statement on a single line
C:110:scan_code: More than one statement on a single line
C:114:scan_code: More than one statement on a single line
C:117:scan_code: More than one statement on a single line
C:123:scan_code: More than one statement on a single line
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
You can disable these messages for &lt;tt&gt;scan_code&lt;/tt&gt; function. &lt;tt&gt;# pylint: disable-msg=...&lt;/tt&gt; style comment can be used everywhere in the source code and affects a block or statement.

&lt;/p&gt;&lt;pre&gt;&lt;code&gt;
&lt;strong&gt;# pylint: disable-msg=C0321&lt;/strong&gt;
def scan_code(co, module):
    assert co and module
    if DEBUG: print co.co_filename
    ...
&lt;/code&gt;&lt;/pre&gt;

&lt;h4&gt;See Also&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://lists.logilab.org/pipermail/python-projects/2006-April/000664.html"&gt;[Python-projects] Pylint: Disable-msg for a block or statement?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-4782823635386284706?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/4782823635386284706/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=4782823635386284706' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/4782823635386284706'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/4782823635386284706'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/pylint-disableenable-message-for-block.html' title='pylint: disable/enable message for a block or statement'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-1690405684489199813</id><published>2008-09-23T21:44:00.003+09:00</published><updated>2010-10-05T01:31:07.999+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>The Power of Python's Generator expressions and Tuple pack/unpack</title><content type='html'>&lt;p style="border: 3px solid #58A; padding: 10px"&gt;
This article has been moved to &lt;a href="http://www.polyphrase.com/2008/09/23/the-power-of-pythons-generator-expressions-and-tuple-pack-unpack.html"&gt;http://www.polyphrase.com/2008/09/23/the-power-of-pythons-generator-expressions-and-tuple-pack-unpack.html&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;
Python&amp;#39;s &lt;a href="http://www.python.org/dev/peps/pep-0289/"&gt;Generator expressions&lt;/a&gt; and &lt;a href="http://en.wikibooks.org/wiki/Python_Programming/Tuples#Packing_and_Unpacking"&gt;Tuple pack/unpack&lt;/a&gt; is more powerful than I thought.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;for k, v in d.iteritems():
  if v &amp;gt; 123:
    yield k, v
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
is equivalent to:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;return (item for item in d.iteritems() if item[1] &amp;gt; 123)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
Some simple generators can be coded using Generator expressions, and Tuple pack/unpack is an easy way to return multiple values.
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% python
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
&amp;gt;&amp;gt;&amp;gt; d = {&amp;#39;apple&amp;#39;: 256, &amp;#39;hoge&amp;#39;: 123, &amp;#39;orange&amp;#39;: 555}
&amp;gt;&amp;gt;&amp;gt; 
&amp;gt;&amp;gt;&amp;gt; def fn_yield():
...   for k, v in d.iteritems():
...     if v &amp;gt; 123:
...       yield k, v
... 
&amp;gt;&amp;gt;&amp;gt; def fn_generator():
...   &lt;strong&gt;return (item for item in d.iteritems() if item[1] &amp;gt; 123)&lt;/strong&gt;
... 
&amp;gt;&amp;gt;&amp;gt; for k, v in fn_yield():
...   print k, v
... 
orange 555
apple 256
&amp;gt;&amp;gt;&amp;gt; for k, v in fn_generator():
...   print k, v
... 
orange 555
apple 256
&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-1690405684489199813?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/1690405684489199813/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=1690405684489199813' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/1690405684489199813'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/1690405684489199813'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/power-of-pythons-generator-expressions.html' title='The Power of Python&apos;s Generator expressions and Tuple pack/unpack'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-7954435960708416617</id><published>2008-09-22T14:29:00.004+09:00</published><updated>2010-10-10T14:23:58.878+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>Do you know Universal Newline Support in Python?</title><content type='html'>&lt;p style="border: 3px solid #58A; padding: 10px"&gt;
This article has been moved to &lt;a href="http://www.polyphrase.com/2008/09/22/do-you-know-universal-newline-support-in-python.html"&gt;http://www.polyphrase.com/2008/09/22/do-you-know-universal-newline-support-in-python.html&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;
Do you know &lt;strong&gt;Universal Newline Support&lt;/strong&gt; in &lt;a href="http://www.python.org/"&gt;Python&lt;/a&gt;? To be honest, I didn&amp;#39;t know that. The &lt;a href="http://www.python.org/dev/peps/pep-0278/"&gt;PEP 278&lt;/a&gt; describes in detail:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;
In a Python with universal newline support &lt;tt&gt;open()&lt;/tt&gt; the mode parameter can also be &lt;tt&gt;&amp;quot;U&amp;quot;&lt;/tt&gt;, meaning &lt;em&gt;&amp;quot;open for input as a text file with universal newline interpretation&amp;quot;&lt;/em&gt;.  Mode &lt;tt&gt;&amp;quot;rU&amp;quot;&lt;/tt&gt; is also allowed, for symmetry with &lt;tt&gt;&amp;quot;rb&amp;quot;&lt;/tt&gt;. Mode &lt;tt&gt;&amp;quot;U&amp;quot;&lt;/tt&gt; cannot be combined with other mode flags such as &lt;tt&gt;&amp;quot;+&amp;quot;&lt;/tt&gt;. &lt;strong&gt;Any line ending in the input file will be seen as a &amp;#39;\n&amp;#39; in Python&lt;/strong&gt;, so little other code has to change to handle universal newlines.
&lt;/p&gt;
&lt;p&gt;
Conversion of newlines happens in all calls that read data: &lt;tt&gt;read()&lt;/tt&gt;, &lt;tt&gt;readline()&lt;/tt&gt;, &lt;tt&gt;readlines()&lt;/tt&gt;, etc.
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;
Here is an example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% printf &amp;#39;Hello, World!\r\n&amp;#39; &amp;gt; /tmp/hello.txt
% cat /tmp/hello.txt 
Hello, World!
% python 
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
&lt;strong&gt;&amp;gt;&amp;gt;&amp;gt; open(&amp;#39;/tmp/hello.txt&amp;#39;).read()
&amp;#39;Hello, World!\r\n&amp;#39;
&amp;gt;&amp;gt;&amp;gt; open(&amp;#39;/tmp/hello.txt&amp;#39;, &amp;#39;U&amp;#39;).read()
&amp;#39;Hello, World!\n&amp;#39;
&lt;/strong&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
If Python was built with the &lt;strong&gt;&lt;tt&gt;--with-universal-newlines&lt;/tt&gt;&lt;/strong&gt; option to configure (the default), &lt;a href="http://docs.python.org/lib/bltin-file-objects.html"&gt;File objects&lt;/a&gt; have &lt;strong&gt;&lt;tt&gt;&lt;a href="http://docs.python.org/lib/bltin-file-objects.html#l2h-315"&gt;newlines&lt;/a&gt;&lt;/tt&gt;&lt;/strong&gt; attribute, so testing whether the current Python has universal newline support can be done with:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;if hasattr(sys.__stdout__, &amp;quot;newlines&amp;quot;):
    print &amp;quot;universal line endings&amp;quot;
&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-7954435960708416617?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/7954435960708416617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=7954435960708416617' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/7954435960708416617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/7954435960708416617'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/do-you-know-universal-newline-support.html' title='Do you know Universal Newline Support in Python?'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-7845072624164780475</id><published>2008-09-21T12:39:00.004+09:00</published><updated>2008-09-21T13:13:09.720+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>How to compile Python source file with or without optimization</title><content type='html'>&lt;p&gt;
&lt;tt&gt;&lt;a href="http://docs.python.org/lib/module-pycompile.html"&gt;py_compile&lt;/a&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;a href="http://docs.python.org/lib/module-compileall.html"&gt;compileall&lt;/a&gt;&lt;/tt&gt; module provides functions to generate a byte-code file from a source file. &lt;strong&gt;You can not&lt;/strong&gt;, however, enable or disable byte code optimization at runtime.
&lt;/p&gt;

&lt;p&gt;
The byte code optimization depends the built-in variable &lt;strong&gt;&lt;tt&gt;&lt;a href="http://pyref.infogami.com/__debug__"&gt;__debug__&lt;/a&gt;&lt;/tt&gt;&lt;/strong&gt; in the current interpreter, and &lt;strong&gt;assignments to __debug__ are illegal&lt;/strong&gt;. Python 2.2 (or later) is strict about that.
&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;% python
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) 
[GCC 4.0.1 (Apple Inc. build 5465)] on darwin
Type &amp;quot;help&amp;quot;, &amp;quot;copyright&amp;quot;, &amp;quot;credits&amp;quot; or &amp;quot;license&amp;quot; for more information.
&amp;gt;&amp;gt;&amp;gt; __debug__
True
&amp;gt;&amp;gt;&amp;gt; __debug__ = False
  File &amp;quot;&amp;lt;stdin&amp;gt;&amp;quot;, line 1
SyntaxError: can not assign to __debug__
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
So you can&amp;#39;t enable/disable optimization flag without running another interpreter (using &lt;tt&gt;'-O'&lt;/tt&gt; switch).&lt;/p&gt;

&lt;h4&gt;Example: Using &lt;tt&gt;os.spawnv&lt;/tt&gt; to run and compile files with or without optimization&lt;/h4&gt;
&lt;script src="http://gist.github.com/11835.js"&gt;&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-7845072624164780475?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/7845072624164780475/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=7845072624164780475' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/7845072624164780475'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/7845072624164780475'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/how-to-compile-python-source-file-with.html' title='How to compile Python source file with or without optimization'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-2223450541300915219</id><published>2008-09-15T10:39:00.003+09:00</published><updated>2008-09-15T11:20:10.287+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='unittest'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>assertNone/assertNotNone</title><content type='html'>&lt;p&gt;Why Python &lt;tt&gt;&lt;a href="http://docs.python.org/lib/module-unittest.html"&gt;unittest&lt;/a&gt;&lt;/tt&gt; module lacks &lt;tt&gt;assertNone/assertNotNone&lt;/tt&gt;? I think this lack would cause problems as API misuse. For example:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;obj = factory.make_object()
self.assert_(obj) # must not be None (?)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
I intended to say &amp;quot;&lt;tt&gt;factory.make_object&lt;/tt&gt; must not return &lt;strong&gt;&lt;tt&gt;None&lt;/tt&gt;&lt;/strong&gt;&amp;quot;, but It can fail even &lt;tt&gt;False&lt;/tt&gt; and such an empty object (&lt;tt&gt;0&lt;/tt&gt;, &lt;tt&gt;&amp;quot;&amp;quot;&lt;/tt&gt;, &lt;tt&gt;[]&lt;/tt&gt;, ...).&lt;/p&gt;

&lt;p&gt;
I should have written like:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;obj = factory.make_object()
self.assert_(obj is not None) # must not be None!
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
Repeating that code, however, is so boring, a lot of the visual noise, and error-prone. Writing &lt;tt&gt;assertNone/assertNotNone&lt;/tt&gt;:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;class TestCase(unittest.TestCase):
    &amp;quot;&amp;quot;&amp;quot;Custom TestCase class&amp;quot;&amp;quot;&amp;quot;

    def failUnlessNone(self, expr, msg=None):
        &amp;quot;&amp;quot;&amp;quot;Fail the test unless the expression is None.&amp;quot;&amp;quot;&amp;quot;
        if expr is not None: raise self.failureException, msg

    def failIfNone(self, expr, msg=None):
        &amp;quot;&amp;quot;&amp;quot;Fail the test if the expression is None.&amp;quot;&amp;quot;&amp;quot;
        if expr is None: raise self.failureException, msg

    # Synonyms for assertion methods
    assertNone = failUnlessNone
    assertNotNone = failIfNone
&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-2223450541300915219?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/2223450541300915219/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=2223450541300915219' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/2223450541300915219'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/2223450541300915219'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/assertnoneassertnotnone.html' title='assertNone/assertNotNone'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8777218451156729009.post-8200318967685315628</id><published>2008-09-15T02:23:00.000+09:00</published><updated>2008-09-15T02:24:15.051+09:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='pylint'/><category scheme='http://www.blogger.com/atom/ns#' term='python'/><title type='text'>pylint: -r/--reports option doesn't work</title><content type='html'>&lt;p&gt;
The following &lt;a href="http://www.logilab.org/857"&gt;pylint&lt;/a&gt; command still outputs reports:&lt;/p&gt;

&lt;pre&gt;&lt;code class="prettyprint"&gt;% pylint --reports=no module&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;
versions and environment:&lt;/p&gt;

&lt;pre&gt;&lt;code class="prettyprint"&gt;% uname -a
Darwin macbook3.local 9.4.0 Darwin Kernel Version 9.4.0: Mon Jun  9 19:30:53 PDT 2008; root:xnu-1228.5.20~1/RELEASE_I386 i386
% python --version
Python 2.5.1
% pylint --version
No config file found, using default configuration
pylint 0.15.0,
astng 0.17.3, common 0.35.0
Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26)
[GCC 4.0.1 (Apple Inc. build 5465)]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;
on Mac OS X 10.5.4.&lt;/p&gt;

&lt;p&gt;
I gave a quick look at the &lt;a href="http://www.logilab.org/857"&gt;pylint&lt;/a&gt; source code. Removing &lt;a href="http://docs.python.org/lib/module-optparse.html"&gt;&lt;tt&gt;optparse&lt;/tt&gt;&lt;/a&gt;'s &lt;tt&gt;default&lt;/tt&gt; option fixes this problem (see below), but I don't know why.&lt;/p&gt;


&lt;pre&gt;&lt;code class="prettyprint"&gt;--- pylint_orig/lint.py 2008-09-14 18:49:35.000000000 +0900
+++ /Library/Python/2.5/site-packages/pylint-0.15.0-py2.5.egg/pylint/lint.py 2008-09-14 18:50:07.000000000 +0900
@@ -184,7 +184,7 @@
 Reports (if any) will be written in a file name &amp;quot;pylint_global.[txt|html]&amp;quot;.'}),
                
                ('reports',
-                {'default': 1, 'type' : 'yn', 'metavar' : '',
+                {'type' : 'yn', 'metavar' : '',
                  'short': 'r',
                  'group': 'Reports',
                  'help' : 'Tells wether to display a full report or only the\
&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8777218451156729009-8200318967685315628?l=polyphrase.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://polyphrase.blogspot.com/feeds/8200318967685315628/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8777218451156729009&amp;postID=8200318967685315628' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/8200318967685315628'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8777218451156729009/posts/default/8200318967685315628'/><link rel='alternate' type='text/html' href='http://polyphrase.blogspot.com/2008/09/pylint-r-reports-option-doesnt-work.html' title='pylint: -r/--reports option doesn&apos;t work'/><author><name>Takanori Ishikawa</name><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
