<?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: A few more Python thoughts from a Perl guy</title>
	<atom:link href="http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/feed/" rel="self" type="application/rss+xml" />
	<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/</link>
	<description>escape colon w q</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:30:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: /dev/null</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15564</link>
		<dc:creator>/dev/null</dc:creator>
		<pubDate>Thu, 05 Jun 2008 12:57:46 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15564</guid>
		<description>This may be interesting to you&lt;br&gt;&lt;a href=&quot;http://www.dwheeler.com/readable/readable-s-expressions.html&quot; rel=&quot;nofollow&quot;&gt;http://www.dwheeler.com/readable/readable-s-exp...&lt;/a&gt;</description>
		<content:encoded><![CDATA[<p>This may be interesting to you<br /><a href="http://www.dwheeler.com/readable/readable-s-expressions.html" rel="nofollow"></a><a href="http://www.dwheeler.com/readable/readable-s-exp.." rel="nofollow">http://www.dwheeler.com/readable/readable-s-exp..</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Savvu</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15565</link>
		<dc:creator>Savvu</dc:creator>
		<pubDate>Wed, 04 Jun 2008 19:42:52 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15565</guid>
		<description>The comment on discouraging the use features is just the opinion of the author of the book. It may be shared by some other people in the Python community but that still does not make it the &quot;true&quot; rationale behind these decisions!&lt;br&gt;&lt;br&gt;A lambda function is a value. You can embed it anywhere in the middle of an expression, in nested parentheses, etc. Just try to design your own syntax for Python lambdas that allows multiple statements, ifs, fors, etc and you will quickly realize why it was done the way it is. It would require an alternative syntax for blocks that uses something other than indentation. It&#039;s not like someone has gone out of his way to discourage people from building more complex lambda functions. It was simply considered not worth the effort to invent a convoluted new syntax for it which would not be very pythonic. The alternative (write a local function and pass its name) is probably more readable, anyway, for anything longer than fits comfortably in a short lambda. It&#039;s not a value judgement - just a pragmatic choice.&lt;br&gt;&lt;br&gt;The same is true for the trinary operator. Any other syntax would not be consistent with Python&#039;s syntax which is based on keywords, not magical runes. Python, unlike javascript and some other languages, does not assume the programmer necessarily has previous knowledge of C. You can understand Python&#039;s trinary operator the first time you encounter it without any explanations. It only looks strange to you because it&#039;s different from your C experience. &lt;br&gt;&lt;br&gt;You can safely ignore this kind of silly opinions about discouraging the use of features. Outside of a few minor warts which are being removed in Python 3.0 everything in Python is meant to be used and enjoyed.&lt;br&gt;&lt;br&gt;Python is not &quot;holier than thou&quot;. It simply doesn&#039;t go out of its way to provide multiple ways of doing the same thing when one is enough.</description>
		<content:encoded><![CDATA[<p>The comment on discouraging the use features is just the opinion of the author of the book. It may be shared by some other people in the Python community but that still does not make it the &#8220;true&#8221; rationale behind these decisions!</p>
<p>A lambda function is a value. You can embed it anywhere in the middle of an expression, in nested parentheses, etc. Just try to design your own syntax for Python lambdas that allows multiple statements, ifs, fors, etc and you will quickly realize why it was done the way it is. It would require an alternative syntax for blocks that uses something other than indentation. It&#39;s not like someone has gone out of his way to discourage people from building more complex lambda functions. It was simply considered not worth the effort to invent a convoluted new syntax for it which would not be very pythonic. The alternative (write a local function and pass its name) is probably more readable, anyway, for anything longer than fits comfortably in a short lambda. It&#39;s not a value judgement &#8211; just a pragmatic choice.</p>
<p>The same is true for the trinary operator. Any other syntax would not be consistent with Python&#39;s syntax which is based on keywords, not magical runes. Python, unlike javascript and some other languages, does not assume the programmer necessarily has previous knowledge of C. You can understand Python&#39;s trinary operator the first time you encounter it without any explanations. It only looks strange to you because it&#39;s different from your C experience. </p>
<p>You can safely ignore this kind of silly opinions about discouraging the use of features. Outside of a few minor warts which are being removed in Python 3.0 everything in Python is meant to be used and enjoyed.</p>
<p>Python is not &#8220;holier than thou&#8221;. It simply doesn&#39;t go out of its way to provide multiple ways of doing the same thing when one is enough.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dude</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15566</link>
		<dc:creator>dude</dc:creator>
		<pubDate>Wed, 04 Jun 2008 10:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15566</guid>
		<description>There&#039;s a major downside to this approach, though:&lt;br&gt;&lt;br&gt;x = ( callMeIfFalse(), callMeIfTrue() )[ condition ]&lt;br&gt;&lt;br&gt;both functions get called, and the value for x is chosen from the constructed tuple (since false evaluates to the 0th element of the tuple and true evaluates to the 1st). So you can&#039;t decide behavior using this method wheras you could do (in Ruby, but it&#039;s nearly identical in perl):&lt;br&gt;&lt;br&gt;x = condition ? callMeIfTrue() : callMeIfFalse()</description>
		<content:encoded><![CDATA[<p>There&#39;s a major downside to this approach, though:</p>
<p>x = ( callMeIfFalse(), callMeIfTrue() )[ condition ]</p>
<p>both functions get called, and the value for x is chosen from the constructed tuple (since false evaluates to the 0th element of the tuple and true evaluates to the 1st). So you can&#39;t decide behavior using this method wheras you could do (in Ruby, but it&#39;s nearly identical in perl):</p>
<p>x = condition ? callMeIfTrue() : callMeIfFalse()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JS</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15567</link>
		<dc:creator>JS</dc:creator>
		<pubDate>Wed, 04 Jun 2008 09:51:49 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15567</guid>
		<description>The Python ternary operator was added because of the widespread use of and/or in the language before it was created.  See for example the description provided in Dive into Python: &lt;a href=&quot;http://www.diveintopython.org/power_of_introspection/and_or.html&quot; rel=&quot;nofollow&quot;&gt;http://www.diveintopython.org/power_of_introspe...&lt;/a&gt;&lt;br&gt;&lt;br&gt;Compared to that sort of construct, X if Y else Z is much cleaner to use.</description>
		<content:encoded><![CDATA[<p>The Python ternary operator was added because of the widespread use of and/or in the language before it was created.  See for example the description provided in Dive into Python: <a href="http://www.diveintopython.org/power_of_introspection/and_or.html" rel="nofollow"></a><a href="http://www.diveintopython.org/power_of_introspe.." rel="nofollow">http://www.diveintopython.org/power_of_introspe..</a>.</p>
<p>Compared to that sort of construct, X if Y else Z is much cleaner to use.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15568</link>
		<dc:creator>Hans</dc:creator>
		<pubDate>Wed, 04 Jun 2008 07:00:21 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15568</guid>
		<description>I use the and/or construct regularly, but you have to watch out because it doesn&#039;t work in all cases:&lt;br&gt;&lt;br&gt;&gt;&gt;&gt; True and 0 or 42&lt;br&gt;42</description>
		<content:encoded><![CDATA[<p>I use the and/or construct regularly, but you have to watch out because it doesn&#39;t work in all cases:</p>
<p>&gt;&gt;&gt; True and 0 or 42<br />42</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: felix</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15569</link>
		<dc:creator>felix</dc:creator>
		<pubDate>Wed, 04 Jun 2008 06:26:20 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15569</guid>
		<description>Just to be clear, though, that&#039;s not a true ternary operator since it relies on the &quot;truth&quot; of &#039;yes&#039; position. The Python ternary is that undead() if &#039;yes&#039; else &#039;grr. argh.&#039; - I was just noting that it&#039;s an odd construction and if its purpose was (as printed in the book) to discourage use, well, I don&#039;t appreciate that in language design. It isn&#039;t a big deal, really, I mean, the if/else construction is obvious and concise, it&#039;s just the philosophy behind doing it that way that I was commenting on.&lt;br&gt;&lt;br&gt;Also, I talk about Python&#039;s anonymous functions above... I just kind of dislike that they&#039;re hobbled. As Hans suggests, this may be a limitation of significant white space syntax - I still dislike it. :)</description>
		<content:encoded><![CDATA[<p>Just to be clear, though, that&#39;s not a true ternary operator since it relies on the &#8220;truth&#8221; of &#39;yes&#39; position. The Python ternary is that undead() if &#39;yes&#39; else &#39;grr. argh.&#39; &#8211; I was just noting that it&#39;s an odd construction and if its purpose was (as printed in the book) to discourage use, well, I don&#39;t appreciate that in language design. It isn&#39;t a big deal, really, I mean, the if/else construction is obvious and concise, it&#39;s just the philosophy behind doing it that way that I was commenting on.</p>
<p>Also, I talk about Python&#39;s anonymous functions above&#8230; I just kind of dislike that they&#39;re hobbled. As Hans suggests, this may be a limitation of significant white space syntax &#8211; I still dislike it. :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: numix</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15570</link>
		<dc:creator>numix</dc:creator>
		<pubDate>Wed, 04 Jun 2008 06:24:57 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15570</guid>
		<description>You can easily replicate ternary functionality using tuples then the conditional to select the appropriate one. e.g.&lt;br&gt;&gt;&gt;&gt; (&quot;b&quot;, &quot;a&quot;)[True]&lt;br&gt;&#039;a&#039;&lt;br&gt;&gt;&gt;&gt; (&quot;b&quot;, &quot;a&quot;)[False]&lt;br&gt;&#039;b&#039;&lt;br&gt; Sure it&#039;s backwards, but it&#039;s rather easy to understand. &lt;br&gt;If you want it to read like a typical ternary, you can do &#039;cond and &quot;a&quot; or &quot;b&quot; &#039; to achieve the same result.&lt;br&gt;e.g.&lt;br&gt;&gt;&gt;&gt; True and &quot;a&quot; or &quot;b&quot;&lt;br&gt;&#039;a&#039;&lt;br&gt;&gt;&gt;&gt; False and &quot;a&quot; or &quot;b&quot;&lt;br&gt;&#039;b&#039;</description>
		<content:encoded><![CDATA[<p>You can easily replicate ternary functionality using tuples then the conditional to select the appropriate one. e.g.<br />&gt;&gt;&gt; (&#8220;b&#8221;, &#8220;a&#8221;)[True]<br />&#39;a&#39;<br />&gt;&gt;&gt; (&#8220;b&#8221;, &#8220;a&#8221;)[False]<br />&#39;b&#39;<br /> Sure it&#39;s backwards, but it&#39;s rather easy to understand. <br />If you want it to read like a typical ternary, you can do &#39;cond and &#8220;a&#8221; or &#8220;b&#8221; &#39; to achieve the same result.<br />e.g.<br />&gt;&gt;&gt; True and &#8220;a&#8221; or &#8220;b&#8221;<br />&#39;a&#39;<br />&gt;&gt;&gt; False and &#8220;a&#8221; or &#8220;b&#8221;<br />&#39;b&#39;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: random guy</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15571</link>
		<dc:creator>random guy</dc:creator>
		<pubDate>Wed, 04 Jun 2008 06:18:59 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15571</guid>
		<description>Python does actually have a ternary, but it looks different from a c ternary:&lt;br&gt;&lt;br&gt;$is_zombie = undead() ? &#039;yes&#039; : &#039;grr. argh.&#039;;&lt;br&gt;becomes:&lt;br&gt;is_zombie = undead() and &#039;yes&#039; or &#039;grr. argh.&#039;&lt;br&gt;&lt;br&gt;And obviously, python does have anonymous functions as another commentor pointed out</description>
		<content:encoded><![CDATA[<p>Python does actually have a ternary, but it looks different from a c ternary:</p>
<p>$is_zombie = undead() ? &#39;yes&#39; : &#39;grr. argh.&#39;;<br />becomes:<br />is_zombie = undead() and &#39;yes&#39; or &#39;grr. argh.&#39;</p>
<p>And obviously, python does have anonymous functions as another commentor pointed out</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hans</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15572</link>
		<dc:creator>Hans</dc:creator>
		<pubDate>Wed, 04 Jun 2008 05:54:53 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15572</guid>
		<description>Hmm, the reason lambdas are crippled is because it&#039;s awkward (to say the least) to have an indentation-based function body inside an expression. If you write a multi-line function, you might as well just use def, anyway. &lt;br&gt;&lt;br&gt;I wasn&#039;t aware that these features are &quot;discouraged&quot;... first time I hear about it.  I must say that Python&#039;s ternary operator is really ugly, though. I avoid it whenever possible.</description>
		<content:encoded><![CDATA[<p>Hmm, the reason lambdas are crippled is because it&#39;s awkward (to say the least) to have an indentation-based function body inside an expression. If you write a multi-line function, you might as well just use def, anyway. </p>
<p>I wasn&#39;t aware that these features are &#8220;discouraged&#8221;&#8230; first time I hear about it.  I must say that Python&#39;s ternary operator is really ugly, though. I avoid it whenever possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: llimllib</title>
		<link>http://comments.deasil.com/2008/06/03/a-few-more-python-thoughts-from-a-perl-guy/comment-page-1/#comment-15573</link>
		<dc:creator>llimllib</dc:creator>
		<pubDate>Wed, 04 Jun 2008 05:54:42 +0000</pubDate>
		<guid isPermaLink="false">http://comments.deasil.com/?p=1645#comment-15573</guid>
		<description>Sam, I replied to you but the disqus comments thingy got freaked out when I typed the wrong password. Look below.</description>
		<content:encoded><![CDATA[<p>Sam, I replied to you but the disqus comments thingy got freaked out when I typed the wrong password. Look below.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

