<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"	>
<channel>
	<title>Comments on: Python common mistakes</title>
	<atom:link href="http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/feed/" rel="self" type="application/rss+xml" />
	<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/</link>
	<description>Pisco Sour is GNOME's official cocktail</description>
	<lastBuildDate>Mon, 27 Jul 2009 07:36:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: diegoe</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-108</link>
		<dc:creator>diegoe</dc:creator>
		<pubDate>Thu, 28 May 2009 20:16:15 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-108</guid>
		<description>@apol: Mmm, good idea. Will remember that next time, thanks.</description>
		<content:encoded><![CDATA[<p>@<a href="http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/#comment-107">apol</a>: Mmm, good idea. Will remember that next time, thanks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: apol</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-107</link>
		<dc:creator>apol</dc:creator>
		<pubDate>Wed, 27 May 2009 17:44:04 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-107</guid>
		<description>When showing code mistakes, never mark the wrong ones in bold but the correct ones. You will make your point better.</description>
		<content:encoded><![CDATA[<p>When showing code mistakes, never mark the wrong ones in bold but the correct ones. You will make your point better.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: engla</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-106</link>
		<dc:creator>engla</dc:creator>
		<pubDate>Mon, 25 May 2009 22:21:46 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-106</guid>
		<description>@stephan: It is pythonic if the condition is long and in several parts (like .. &amp;&amp; .. &#124;&#124; .. ) etc. The pythonic way to do line continuations is using brackets.</description>
		<content:encoded><![CDATA[<p>@stephan: It is pythonic if the condition is long and in several parts (like .. &amp;&amp; .. || .. ) etc. The pythonic way to do line continuations is using brackets.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vincent Noel</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-105</link>
		<dc:creator>Vincent Noel</dc:creator>
		<pubDate>Mon, 25 May 2009 12:26:07 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-105</guid>
		<description>Instead of &quot;if a is not None&quot; and &quot;if a is None&quot;, can&#039;t we just write &quot;if a&quot; and &quot;if not a&quot;? This solution is advocated here: http://jaynes.colorado.edu/PythonIdioms.html</description>
		<content:encoded><![CDATA[<p>Instead of &#8220;if a is not None&#8221; and &#8220;if a is None&#8221;, can&#8217;t we just write &#8220;if a&#8221; and &#8220;if not a&#8221;? This solution is advocated here: <a href="http://jaynes.colorado.edu/PythonIdioms.html" rel="nofollow">http://jaynes.colorado.edu/PythonIdioms.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan Puchegger</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-104</link>
		<dc:creator>Stephan Puchegger</dc:creator>
		<pubDate>Mon, 25 May 2009 07:44:27 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-104</guid>
		<description>I agree that 

if (condition):

is not &quot;pythonic&quot; and does not adhere the PEP 8 style guidelines, but it is not a mistake, since it is valid and does what one would expect it to do. Yes the &quot;(&quot; and &quot;)&quot; are unneeded in this case, but for some they are a welcome sign where the condition begins and where it ends. A style guideline is not a law after all and those who wrote the style guideline introduced their own subjective preferences.</description>
		<content:encoded><![CDATA[<p>I agree that </p>
<p>if (condition):</p>
<p>is not &#8220;pythonic&#8221; and does not adhere the PEP 8 style guidelines, but it is not a mistake, since it is valid and does what one would expect it to do. Yes the &#8220;(&#8221; and &#8220;)&#8221; are unneeded in this case, but for some they are a welcome sign where the condition begins and where it ends. A style guideline is not a law after all and those who wrote the style guideline introduced their own subjective preferences.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paddy3118</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-103</link>
		<dc:creator>Paddy3118</dc:creator>
		<pubDate>Mon, 25 May 2009 04:20:39 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-103</guid>
		<description>@rvl:
 Your item 3 on Duck Typing, is it a problem for you? I find Duck Typing works fine for me.</description>
		<content:encoded><![CDATA[<p>@rvl:<br />
 Your item 3 on Duck Typing, is it a problem for you? I find Duck Typing works fine for me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diegoe</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-101</link>
		<dc:creator>diegoe</dc:creator>
		<pubDate>Sun, 24 May 2009 18:16:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-101</guid>
		<description>@Sebastian nice explanation, thank you</description>
		<content:encoded><![CDATA[<p>@Sebastian nice explanation, thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: diegoe</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-100</link>
		<dc:creator>diegoe</dc:creator>
		<pubDate>Sun, 24 May 2009 18:14:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-100</guid>
		<description>@mezo: mmm, didn&#039;t get that one</description>
		<content:encoded><![CDATA[<p>@<a href="http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/#comment-99">mezo</a>: mmm, didn&#8217;t get that one</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mezo</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-99</link>
		<dc:creator>mezo</dc:creator>
		<pubDate>Sun, 24 May 2009 18:09:06 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-99</guid>
		<description>I see often something like this:

a = [&#039;kasdoasudiasud90as9u8d0asdijasodjaiso&#039;, &#039;ksdaosjdiasu9023u8e9i0ajdi23ui0euqw0du9q0&#039;,&#039;0-230asd0a-s9d0-as9d0-asd0a-sdi0-asid0as-di0as-sdia-&#039;]
for x in a:
    paint(thisandthat)
instead of for int in a.</description>
		<content:encoded><![CDATA[<p>I see often something like this:</p>
<p>a = ['kasdoasudiasud90as9u8d0asdijasodjaiso', 'ksdaosjdiasu9023u8e9i0ajdi23ui0euqw0du9q0','0-230asd0a-s9d0-as9d0-asd0a-sdi0-asid0as-di0as-sdia-']<br />
for x in a:<br />
    paint(thisandthat)<br />
instead of for int in a.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian</title>
		<link>http://blogs.gnome.org/diegoe/2009/05/23/python-common-mistakes/comment-page-1/#comment-98</link>
		<dc:creator>Sebastian</dc:creator>
		<pubDate>Sun, 24 May 2009 10:24:19 +0000</pubDate>
		<guid isPermaLink="false">http://blogs.gnome.org/diegoe/?p=127#comment-98</guid>
		<description>The difference between &quot;==&quot; and &quot;is&quot; is that the &quot;==&quot; operator calls the __eq__() or __cmp__() method on the first object, and &quot;is&quot; doesn&#039;t. It is possible for some instance or other to compare positively to None, even though that behaviour would be surprising and should be avoided.

Example:


class AlwaysEqual:

    def __eq__(self, other):
        print &#039;__eq__() called&#039;
        return True

x = AlwaysEqual()

print x == None
print x is None


Since someone who compares a variable to None will usually want to know whether or not it has been instantiated, he should use the &quot;is&quot; operator.

This is made rather more explicit in some other languages such as Java, where you have to call one of the two object&#039;s equals() method explicitly. The world&#039;s log files are full of NullPointerExceptions where someone called equals() on null. This is why a general coding recommendation is to always write


&quot;hello&quot;.equals(greeting)


instead of


greeting.equals(&quot;hello&quot;)
</description>
		<content:encoded><![CDATA[<p>The difference between &#8220;==&#8221; and &#8220;is&#8221; is that the &#8220;==&#8221; operator calls the __eq__() or __cmp__() method on the first object, and &#8220;is&#8221; doesn&#8217;t. It is possible for some instance or other to compare positively to None, even though that behaviour would be surprising and should be avoided.</p>
<p>Example:</p>
<p>class AlwaysEqual:</p>
<p>    def __eq__(self, other):<br />
        print &#8216;__eq__() called&#8217;<br />
        return True</p>
<p>x = AlwaysEqual()</p>
<p>print x == None<br />
print x is None</p>
<p>Since someone who compares a variable to None will usually want to know whether or not it has been instantiated, he should use the &#8220;is&#8221; operator.</p>
<p>This is made rather more explicit in some other languages such as Java, where you have to call one of the two object&#8217;s equals() method explicitly. The world&#8217;s log files are full of NullPointerExceptions where someone called equals() on null. This is why a general coding recommendation is to always write</p>
<p>&#8220;hello&#8221;.equals(greeting)</p>
<p>instead of</p>
<p>greeting.equals(&#8221;hello&#8221;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
