<?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/"
		>
<channel>
	<title>Comments on: Concise python code</title>
	<atom:link href="http://blog.dhananjaynene.com/2010/01/concise-python-code/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/</link>
	<description>Dhananjay Nene's opinions on software programming, design, architecture and the internet</description>
	<lastBuildDate>Sun, 28 Feb 2010 03:58:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Dhananjay Nene</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9229</link>
		<dc:creator>Dhananjay Nene</dc:creator>
		<pubDate>Fri, 08 Jan 2010 21:32:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9229</guid>
		<description>&lt;blockquote&gt;I have seen excessive usage of one liners in some high level language code snippets, that’s not wrong at all as long as the programmer has been able to keep the right balance between the code being concise and readable.&lt;/blockquote&gt;

Precisely the point I made in the first four sentences of this blog post.</description>
		<content:encoded><![CDATA[<blockquote><p>I have seen excessive usage of one liners in some high level language code snippets, that’s not wrong at all as long as the programmer has been able to keep the right balance between the code being concise and readable.</p></blockquote>
<p>Precisely the point I made in the first four sentences of this blog post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhananjay Nene</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9228</link>
		<dc:creator>Dhananjay Nene</dc:creator>
		<pubDate>Fri, 08 Jan 2010 21:25:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9228</guid>
		<description>&lt;blockquote&gt;readability of code becomes much more important, especially in the case of high level duck typed languages such as python as compared to other middle level languages such as c++ etc.&lt;/blockquote&gt;

Interesting.</description>
		<content:encoded><![CDATA[<blockquote><p>readability of code becomes much more important, especially in the case of high level duck typed languages such as python as compared to other middle level languages such as c++ etc.</p></blockquote>
<p>Interesting.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashish Yadav</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9227</link>
		<dc:creator>Ashish Yadav</dc:creator>
		<pubDate>Fri, 08 Jan 2010 21:16:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9227</guid>
		<description>[Oops!! submit button got clicked before the response was completed]
Hi Dhananjay,
i agree with most of what you just said. However i would like to state that the readability of code becomes much more important, especially in the case of high level duck typed languages such as python as compared to other middle level languages such as c++ etc.
I agree on how one decides upon the right mixture of brevity,readability and code maintainability can vary from person to person. I have seen excessive usage of one liners in some high level language code snippets, that&#039;s not wrong at all as long as the programmer has been able to keep the right balance between the code being concise and readable. So many times incorrect usage of functional constructs like lambda,reduce without maintaining that delicate balance makes code smelly, though not always.
Above all we pythonistas should always remember &quot; The Zen of Python &quot; :)

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.</description>
		<content:encoded><![CDATA[<p>[Oops!! submit button got clicked before the response was completed]<br />
Hi Dhananjay,<br />
i agree with most of what you just said. However i would like to state that the readability of code becomes much more important, especially in the case of high level duck typed languages such as python as compared to other middle level languages such as c++ etc.<br />
I agree on how one decides upon the right mixture of brevity,readability and code maintainability can vary from person to person. I have seen excessive usage of one liners in some high level language code snippets, that&#8217;s not wrong at all as long as the programmer has been able to keep the right balance between the code being concise and readable. So many times incorrect usage of functional constructs like lambda,reduce without maintaining that delicate balance makes code smelly, though not always.<br />
Above all we pythonistas should always remember &#8221; The Zen of Python &#8221; <img src='http://blog.dhananjaynene.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Beautiful is better than ugly.<br />
Explicit is better than implicit.<br />
Simple is better than complex.<br />
Complex is better than complicated.<br />
Flat is better than nested.<br />
Sparse is better than dense.<br />
Readability counts.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashish Yadav</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9226</link>
		<dc:creator>Ashish Yadav</dc:creator>
		<pubDate>Fri, 08 Jan 2010 20:52:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9226</guid>
		<description>Hi Dhananjay,
i agree with most of what you just said. However i would like to state that the readability of code becomes much more important, especially in the case of high level duck typed languages such as python as compared to other middle level languages such as c++ etc.
As one tends to give more freedom of expression to programmer, the code also reflects much more to his state of mind then some one else may understand.</description>
		<content:encoded><![CDATA[<p>Hi Dhananjay,<br />
i agree with most of what you just said. However i would like to state that the readability of code becomes much more important, especially in the case of high level duck typed languages such as python as compared to other middle level languages such as c++ etc.<br />
As one tends to give more freedom of expression to programmer, the code also reflects much more to his state of mind then some one else may understand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhananjay Nene</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9225</link>
		<dc:creator>Dhananjay Nene</dc:creator>
		<pubDate>Fri, 08 Jan 2010 17:56:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9225</guid>
		<description>Ashish,

I look forward to continuing to use reduce in Python 3000 from the &lt;a href=&quot;http://docs.python.org/library/functools.html&quot; rel=&quot;nofollow&quot;&gt;functools&lt;/a&gt; package, as much as I am likely to also want to use &lt;em&gt;functools.partial&lt;/em&gt;. The issue isn&#039;t coolness, it is appropriateness. There are a number of scenarios where as an example, writing a separate function and passing it to another which uses it in a for loop, or in a map / apply / reduce function helps separate different concerns. I fully believe using these capabilities to achieve separation of concerns (where appropriate and applicable) is extremely helpful in terms of improving maintainability and testability of code. In fact in a larger number of cases, I have observed that using functions through such functional constructs helps substantially improve testability. Maybe a 100 line function looks cool when it is similar to a 100 line pseudocode, but break it down and you are likely to get a much better testable software and concise code even though the code may not be as obvious. Decomposition is a matter of taste, judgement and consistency with a set of priorities. I don&#039;t think there is one way which is necessarily superior to another.

Python&#039;s awesomeness lies in the fact that it allows you to write code which is consistent with your design thoughts, philosophies and temporal objectives. It doesn&#039;t require you to choose between object oriented, functional or for that matter even the traditional procedural programming. That diversity is what makes it healthy.

Having said that I do believe, there are likely to be some situations where our opinions may differ.
&lt;ul&gt;
	&lt;li&gt;I think there are likely to be many situations where brevity increases readability. However that is a possibility not a rule. Brevity could but doesn&#039;t always improve maintainability&lt;/li&gt;
	&lt;li&gt;I believe there are more factors than just fealty to pseudocode. Testability and separation of concerns as I mentioned above are some. Improved ability to deal with concurrency might be another. &lt;/li&gt;
&lt;/ul&gt;</description>
		<content:encoded><![CDATA[<p>Ashish,</p>
<p>I look forward to continuing to use reduce in Python 3000 from the <a href="http://docs.python.org/library/functools.html" rel="nofollow">functools</a> package, as much as I am likely to also want to use <em>functools.partial</em>. The issue isn&#8217;t coolness, it is appropriateness. There are a number of scenarios where as an example, writing a separate function and passing it to another which uses it in a for loop, or in a map / apply / reduce function helps separate different concerns. I fully believe using these capabilities to achieve separation of concerns (where appropriate and applicable) is extremely helpful in terms of improving maintainability and testability of code. In fact in a larger number of cases, I have observed that using functions through such functional constructs helps substantially improve testability. Maybe a 100 line function looks cool when it is similar to a 100 line pseudocode, but break it down and you are likely to get a much better testable software and concise code even though the code may not be as obvious. Decomposition is a matter of taste, judgement and consistency with a set of priorities. I don&#8217;t think there is one way which is necessarily superior to another.</p>
<p>Python&#8217;s awesomeness lies in the fact that it allows you to write code which is consistent with your design thoughts, philosophies and temporal objectives. It doesn&#8217;t require you to choose between object oriented, functional or for that matter even the traditional procedural programming. That diversity is what makes it healthy.</p>
<p>Having said that I do believe, there are likely to be some situations where our opinions may differ.</p>
<ul>
<li>I think there are likely to be many situations where brevity increases readability. However that is a possibility not a rule. Brevity could but doesn&#8217;t always improve maintainability</li>
<li>I believe there are more factors than just fealty to pseudocode. Testability and separation of concerns as I mentioned above are some. Improved ability to deal with concurrency might be another. </li>
</ul>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashish Yadav</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9224</link>
		<dc:creator>Ashish Yadav</dc:creator>
		<pubDate>Fri, 08 Jan 2010 17:26:42 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9224</guid>
		<description>You can also read another great article titled &quot; The fate of reduce() in Python 3000 &quot; http://www.artima.com/weblogs/viewpost.jsp?thread=98196.
Though i could never understand what is so great with one liners except to look cool in the game of code golfing. 
1)Does it increase readability? I don&#039;t think so. IMHO if one can write concise code it&#039;s good, but counting lines never looked like a criteria to judge a piece of code to me.
2)usage of Lambdas. Certainly there may be situations where using lambdas may make code more readable. But just like design patterns they should not be used just to look cool.

Python&#039;s awesomeness lies in the fact that it allows you to write code which will be as readable as in pseudocode, or in another words executable pseudocode.
The question one should ask himself while writing code in python should be, is this the way i will explain what the code is trying to do in pseudocode, also does the concept of one liner makes sense in pseudocode as well.</description>
		<content:encoded><![CDATA[<p>You can also read another great article titled &#8221; The fate of reduce() in Python 3000 &#8221; <a href="http://www.artima.com/weblogs/viewpost.jsp?thread=98196" rel="nofollow">http://www.artima.com/weblogs/viewpost.jsp?thread=98196</a>.<br />
Though i could never understand what is so great with one liners except to look cool in the game of code golfing.<br />
1)Does it increase readability? I don&#8217;t think so. IMHO if one can write concise code it&#8217;s good, but counting lines never looked like a criteria to judge a piece of code to me.<br />
2)usage of Lambdas. Certainly there may be situations where using lambdas may make code more readable. But just like design patterns they should not be used just to look cool.</p>
<p>Python&#8217;s awesomeness lies in the fact that it allows you to write code which will be as readable as in pseudocode, or in another words executable pseudocode.<br />
The question one should ask himself while writing code in python should be, is this the way i will explain what the code is trying to do in pseudocode, also does the concept of one liner makes sense in pseudocode as well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhananjay Nene</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9221</link>
		<dc:creator>Dhananjay Nene</dc:creator>
		<pubDate>Fri, 08 Jan 2010 03:52:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9221</guid>
		<description>Bernd,

I reread Lau&#039;s post and it isn&#039;t obvious whether he wanted the ordered semantics (per the text), though the code does reflect the ordered semantics. So assuming ordered semantics is required, the second solution would be the way to go.</description>
		<content:encoded><![CDATA[<p>Bernd,</p>
<p>I reread Lau&#8217;s post and it isn&#8217;t obvious whether he wanted the ordered semantics (per the text), though the code does reflect the ordered semantics. So assuming ordered semantics is required, the second solution would be the way to go.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bernd Schiffer</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9220</link>
		<dc:creator>Bernd Schiffer</dc:creator>
		<pubDate>Thu, 07 Jan 2010 02:02:25 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9220</guid>
		<description>@Stephan: I can&#039;t see the one-liner here due to the ceremony stuff. Can one have less LoC (in Java) than this?
&lt;code lang=&quot;java&quot;&gt;
import java.util.*;
class Main {
	public static void main(String[] args) {
		System.out.println(new ArrayList(new LinkedHashSet(Arrays.asList(&quot;foo&quot;, &quot;bar&quot;, &quot;baz&quot;, &quot;foo&quot;))));
	}
}
&lt;/code&gt;
@Dhananjay: I think you&#039;re solution with Python&#039;s &quot;set&quot; is not comparable to the task described in Lau Jensens ceremony blog post, since &quot;set&quot; doesn&#039;t care about the order of the elements. But Lau&#039;s task was to only &quot;remove duplicats&quot;, i.e. list as input, list as output, no change in the order of the elements left.

Your algorithm changed the order to &#039;baz&#039;, &#039;foo&#039;, &#039;bar&#039;, which would remove the duplicates and changes the order. The same would be true for the Java solution if I wouldn&#039;t use LinkedHashMap instead of HashMap.

Thanks for that nice blog post! I really enjoyed reading it :)</description>
		<content:encoded><![CDATA[<p>@Stephan: I can&#8217;t see the one-liner here due to the ceremony stuff. Can one have less LoC (in Java) than this?</p>
<div class="codecolorer-container java dawn" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="java codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.*</span><span style="color: #339933;">;</span><br />
<span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarraylist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ArrayList</span></a><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LinkedHashSet<span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarrays+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Arrays</span></a>.<span style="color: #006633;">asList</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;foo&quot;</span>, <span style="color: #0000ff;">&quot;bar&quot;</span>, <span style="color: #0000ff;">&quot;baz&quot;</span>, <span style="color: #0000ff;">&quot;foo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>@Dhananjay: I think you&#8217;re solution with Python&#8217;s &#8220;set&#8221; is not comparable to the task described in Lau Jensens ceremony blog post, since &#8220;set&#8221; doesn&#8217;t care about the order of the elements. But Lau&#8217;s task was to only &#8220;remove duplicats&#8221;, i.e. list as input, list as output, no change in the order of the elements left.</p>
<p>Your algorithm changed the order to &#8216;baz&#8217;, &#8216;foo&#8217;, &#8216;bar&#8217;, which would remove the duplicates and changes the order. The same would be true for the Java solution if I wouldn&#8217;t use LinkedHashMap instead of HashMap.</p>
<p>Thanks for that nice blog post! I really enjoyed reading it <img src='http://blog.dhananjaynene.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dhananjay Nene</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9218</link>
		<dc:creator>Dhananjay Nene</dc:creator>
		<pubDate>Wed, 06 Jan 2010 07:09:09 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9218</guid>
		<description>Stephan,

Yes, am in full agreement on the LOC comment. On the Java HashSet matter, yes thats what a good java programmer would want to do. Though even under a shorter code, the implication of the ceremony (boilerplate) will not be lost. Again goes back to my point of selecting appropriate pieces of code to draw inferences and learnings from.

Dhananjay</description>
		<content:encoded><![CDATA[<p>Stephan,</p>
<p>Yes, am in full agreement on the LOC comment. On the Java HashSet matter, yes thats what a good java programmer would want to do. Though even under a shorter code, the implication of the ceremony (boilerplate) will not be lost. Again goes back to my point of selecting appropriate pieces of code to draw inferences and learnings from.</p>
<p>Dhananjay</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan Schmidt</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9217</link>
		<dc:creator>Stephan Schmidt</dc:creator>
		<pubDate>Tue, 05 Jan 2010 20:43:20 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9217</guid>
		<description>Concerning the Java solution: Using HashSet makes the solution a one-liner in Java too (someone mentions this in the comments).

Cheers
Stephan</description>
		<content:encoded><![CDATA[<p>Concerning the Java solution: Using HashSet makes the solution a one-liner in Java too (someone mentions this in the comments).</p>
<p>Cheers<br />
Stephan</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stephan Schmidt</title>
		<link>http://blog.dhananjaynene.com/2010/01/concise-python-code/comment-page-1/#comment-9216</link>
		<dc:creator>Stephan Schmidt</dc:creator>
		<pubDate>Tue, 05 Jan 2010 20:41:02 +0000</pubDate>
		<guid isPermaLink="false">http://blog.dhananjaynene.com/?p=937#comment-9216</guid>
		<description>Nice post, LOC comparisons are tricky, but done right we can all learn something.

Cheers
Stephan</description>
		<content:encoded><![CDATA[<p>Nice post, LOC comparisons are tricky, but done right we can all learn something.</p>
<p>Cheers<br />
Stephan</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.677 seconds -->
