<?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: An Academic Inconvenience of Python</title>
	<atom:link href="http://push.cx/2007/an-academic-inconvenience-of-python/feed" rel="self" type="application/rss+xml" />
	<link>http://push.cx/2007/an-academic-inconvenience-of-python</link>
	<description>A traveling geek&#039;s blog on development, games, and the web</description>
	<lastBuildDate>Tue, 17 Jan 2012 16:49:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: Caching Dictionaries in Python vs. Ruby - Push cx</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-87348</link>
		<dc:creator>Caching Dictionaries in Python vs. Ruby - Push cx</dc:creator>
		<pubDate>Sat, 02 Feb 2008 18:02:05 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-87348</guid>
		<description>[...] A while ago I made a slightly-underinformed post (see the corrections in the comments) trying to draw a difference between Python and Ruby. I&#8217;ve finally got a decent example and can explain what I&#8217;m getting at. [...]</description>
		<content:encoded><![CDATA[<p>[...] A while ago I made a slightly-underinformed post (see the corrections in the comments) trying to draw a difference between Python and Ruby. I&#8217;ve finally got a decent example and can explain what I&#8217;m getting at. [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Storch</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84871</link>
		<dc:creator>Jim Storch</dc:creator>
		<pubDate>Fri, 09 Nov 2007 19:42:16 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84871</guid>
		<description>Oops, one too many characters.  Make that:

^(.{,254}[.!?])</description>
		<content:encoded><![CDATA[<p>Oops, one too many characters.  Make that:</p>
<p>^(.{,254}[.!?])</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim Storch</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84859</link>
		<dc:creator>Jim Storch</dc:creator>
		<pubDate>Fri, 09 Nov 2007 14:33:03 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84859</guid>
		<description>If you want to use regular expressions, this should do the trick:

^(.{,255}[.!?])

I&#039;m not the fan of clever one-liners that I used to be.  They seem out of place in Python.

Cheers.</description>
		<content:encoded><![CDATA[<p>If you want to use regular expressions, this should do the trick:</p>
<p>^(.{,255}[.!?])</p>
<p>I&#8217;m not the fan of clever one-liners that I used to be.  They seem out of place in Python.</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phil Hassey</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84798</link>
		<dc:creator>Phil Hassey</dc:creator>
		<pubDate>Thu, 08 Nov 2007 17:51:25 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84798</guid>
		<description>A shorter way (that works):

&lt;code&gt;s[:max([s.rfind(c,0,255) for c in &quot;.!?&quot;])+1]&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>A shorter way (that works):</p>
<p><code>s[:max([s.rfind(c,0,255) for c in ".!?"])+1]</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84797</link>
		<dc:creator>Kevin</dc:creator>
		<pubDate>Thu, 08 Nov 2007 17:19:45 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84797</guid>
		<description>Academic roots of Python the problem. Nah. First of all your example is missing a right paren to close the max function. Next, I just don’t see how your logic is going to work, maybe I’m missing something, but it looks to me that the value of s in the right  index is going refer to the original longer string. rfind seems to be a better choice. This or a variant seems to be closer to to what your looking for:
    s[:max(s[:255].rfind(&#039;.&#039;), s[:255].rfind(&#039;!&#039;), s[:255].find(&#039;?&#039;))+1]
A little clunkier, but it seems to work.</description>
		<content:encoded><![CDATA[<p>Academic roots of Python the problem. Nah. First of all your example is missing a right paren to close the max function. Next, I just don’t see how your logic is going to work, maybe I’m missing something, but it looks to me that the value of s in the right  index is going refer to the original longer string. rfind seems to be a better choice. This or a variant seems to be closer to to what your looking for:<br />
    s[:max(s[:255].rfind(&#8216;.&#8217;), s[:255].rfind(&#8216;!&#8217;), s[:255].find(&#8216;?&#8217;))+1]<br />
A little clunkier, but it seems to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Harkins</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84796</link>
		<dc:creator>Peter Harkins</dc:creator>
		<pubDate>Thu, 08 Nov 2007 17:17:05 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84796</guid>
		<description>John: Yeah, you&#039;re right. I just tested and found I had to write:

&lt;code lang=&quot;python&quot;&gt;
s[:max(s[:255].rfind(&quot;.&quot;), s[:255].rfind(&quot;!&quot;), s[:255].rfind(&quot;?&quot;)) + 1]
&lt;/code&gt;

The code was slightly different in the script I wrote (two lines, had a temp var) for unrelated actions and I ran it together for the post.</description>
		<content:encoded><![CDATA[<p>John: Yeah, you&#8217;re right. I just tested and found I had to write:</p>
<pre>&nbsp;
s<span style="color: #66cc66;">&#91;</span>:<span style="color: #b1b100;">max</span><span style="color: #66cc66;">&#40;</span>s<span style="color: #66cc66;">&#91;</span>:<span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #202020;">rfind</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"."</span><span style="color: #66cc66;">&#41;</span>, s<span style="color: #66cc66;">&#91;</span>:<span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #202020;">rfind</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"!"</span><span style="color: #66cc66;">&#41;</span>, s<span style="color: #66cc66;">&#91;</span>:<span style="color: #cc66cc;">255</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #202020;">rfind</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"?"</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span></pre>
<p>The code was slightly different in the script I wrote (two lines, had a temp var) for unrelated actions and I ran it together for the post.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daivd</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84795</link>
		<dc:creator>Daivd</dc:creator>
		<pubDate>Thu, 08 Nov 2007 17:04:13 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84795</guid>
		<description>This is why the regexp module (re) exists (and rfind as others have pointed out). If you had to use rindex, you could do the hack approach and prepend the string with &#039;!?.&#039; :)</description>
		<content:encoded><![CDATA[<p>This is why the regexp module (re) exists (and rfind as others have pointed out). If you had to use rindex, you could do the hack approach and prepend the string with &#8216;!?.&#8217; :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: John Carr</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84794</link>
		<dc:creator>John Carr</dc:creator>
		<pubDate>Thu, 08 Nov 2007 16:58:37 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84794</guid>
		<description>Can you really use s like that? Consider which of these 2 variants - which would python execute internally?

a = s[:255]
s = [:max(a.rfind(’.&#039;), a.rfind(’!&#039;), a.rfind(’x&#039;) + 1)]

a = s[:255]
s = [:max(s.rfind(’.&#039;), s.rfind(’!&#039;), s.rfind(’x&#039;) + 1)]

If &#039;s&#039; somehow mutates halfway through the statement i&#039;d consider it somewhat broken, but in order for your one-liner to work.. it would have to ?!?</description>
		<content:encoded><![CDATA[<p>Can you really use s like that? Consider which of these 2 variants &#8211; which would python execute internally?</p>
<p>a = s[:255]<br />
s = [:max(a.rfind(’.'), a.rfind(’!'), a.rfind(’x') + 1)]</p>
<p>a = s[:255]<br />
s = [:max(s.rfind(’.'), s.rfind(’!'), s.rfind(’x') + 1)]</p>
<p>If &#8216;s&#8217; somehow mutates halfway through the statement i&#8217;d consider it somewhat broken, but in order for your one-liner to work.. it would have to ?!?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug Winter</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84790</link>
		<dc:creator>Doug Winter</dc:creator>
		<pubDate>Thu, 08 Nov 2007 16:40:36 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84790</guid>
		<description>re.sub(&#039;[^\.\!\?]+$&#039;, &#039;&#039;, s[:255])</description>
		<content:encoded><![CDATA[<p>re.sub(&#8216;[^\.\!\?]+$&#8217;, &#8221;, s[:255])</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James B.</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84789</link>
		<dc:creator>James B.</dc:creator>
		<pubDate>Thu, 08 Nov 2007 16:40:27 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84789</guid>
		<description>Wouldn&#039;t using rfind instead of rindex work?  It returns -1 when not found rather than raising an exception, and it is even one character less to type!</description>
		<content:encoded><![CDATA[<p>Wouldn&#8217;t using rfind instead of rindex work?  It returns -1 when not found rather than raising an exception, and it is even one character less to type!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Peter Harkins</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84788</link>
		<dc:creator>Peter Harkins</dc:creator>
		<pubDate>Thu, 08 Nov 2007 16:38:13 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84788</guid>
		<description>Phil: Wow, I completely missed rfind. That does indeed work exactly the way I wanted.

Tiberiu: Yeah, I go back and forth over how paranoid I want the language to be about these things by default. I also learned Python after PHP and I saw a lot of PHP bugs come from it being especially &quot;helpful&quot; by coercing types and not complaining about discrepancies.</description>
		<content:encoded><![CDATA[<p>Phil: Wow, I completely missed rfind. That does indeed work exactly the way I wanted.</p>
<p>Tiberiu: Yeah, I go back and forth over how paranoid I want the language to be about these things by default. I also learned Python after PHP and I saw a lot of PHP bugs come from it being especially &#8220;helpful&#8221; by coercing types and not complaining about discrepancies.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tiberiu Ichim</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84785</link>
		<dc:creator>Tiberiu Ichim</dc:creator>
		<pubDate>Thu, 08 Nov 2007 16:32:13 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84785</guid>
		<description>Long, long time ago, when I was came to Python from the PHP world I&#039;ve appreciated Python for exactly this type of behaviour: don&#039;t return stupid &quot;default&quot; values, and instead raise errors when something is not according to the programmer&#039;s wishes.

I, myself, prefer a somewhat longer code, but one that is more easily understood at first glance.</description>
		<content:encoded><![CDATA[<p>Long, long time ago, when I was came to Python from the PHP world I&#8217;ve appreciated Python for exactly this type of behaviour: don&#8217;t return stupid &#8220;default&#8221; values, and instead raise errors when something is not according to the programmer&#8217;s wishes.</p>
<p>I, myself, prefer a somewhat longer code, but one that is more easily understood at first glance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: phil hassey</title>
		<link>http://push.cx/2007/an-academic-inconvenience-of-python/comment-page-1#comment-84783</link>
		<dc:creator>phil hassey</dc:creator>
		<pubDate>Thu, 08 Nov 2007 16:19:25 +0000</pubDate>
		<guid isPermaLink="false">http://push.cx/2007/an-academic-inconvenience-of-python#comment-84783</guid>
		<description>you might try:

&lt;code&gt;s = s[:255][:max(s.rfind(&quot;.&quot;), s.rfind(&quot;!&quot;), s.rfind(&quot;?&quot;)) + 1]&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>you might try:</p>
<p><code>s = s[:255][:max(s.rfind("."), s.rfind("!"), s.rfind("?")) + 1]</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>

