<?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 Python Rant</title>
	<atom:link href="http://www.algorithm.co.il/blogs/programming/python/a-python-rant/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.algorithm.co.il/blogs/programming/a-python-rant/</link>
	<description>Algorithms, for the heck of it</description>
	<lastBuildDate>Tue, 21 Jun 2011 21:07:08 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: Alan</title>
		<link>http://www.algorithm.co.il/blogs/programming/a-python-rant/#comment-173</link>
		<dc:creator>Alan</dc:creator>
		<pubDate>Sun, 08 Mar 2009 02:06:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=197#comment-173</guid>
		<description>I want my money back.

First thing I thought when I saw the title on Reddit was &quot;Oooh, shiny, I like a good rant&quot;

Where&#039;s the rant ?

You cannot rant in less than at least 6 paras (including &gt; 40% ALLCAPs), or 10 paras in lower case.

2 substantial paras abd a few supportings paras does not qualify as a rant.
It&#039;s os merely a whinge.</description>
		<content:encoded><![CDATA[<p>I want my money back.</p>
<p>First thing I thought when I saw the title on Reddit was &#8220;Oooh, shiny, I like a good rant&#8221;</p>
<p>Where&#8217;s the rant ?</p>
<p>You cannot rant in less than at least 6 paras (including &gt; 40% ALLCAPs), or 10 paras in lower case.</p>
<p>2 substantial paras abd a few supportings paras does not qualify as a rant.<br />
It&#8217;s os merely a whinge.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lorg</title>
		<link>http://www.algorithm.co.il/blogs/programming/a-python-rant/#comment-172</link>
		<dc:creator>lorg</dc:creator>
		<pubDate>Tue, 03 Mar 2009 17:32:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=197#comment-172</guid>
		<description>General note:
For those wishing to write code in the comments, enclose your code within a [ python ] and [ / python ] block (just without the spaces :).

Bobby:
Of course, and indeed I wrote up a few of those and put them in my standard utilities import, which by now has grown quite a bit. By the way, instead of izip with count, why not just use enumerate?

Dave:
I disagree, although you are partially correct. Indeed when I thought of find and rfind what I had in mind was looking for a single element&#039;s position (a bit like C&#039;s strchr()). Consider:
[python]
def rfind(some_list, criterion, start_pos=None):
    if start_pos is None:
        start_pos = len(some_list)-1
    for idx in range(start_pos, -1, -1):
        if criterion(some_list[idx]):
            return idx
    return None
[/python]

Now, I admit I wanted these functions mostly for some ad-hoc parsing. Still, it would be nice to split a list on token types, or other delimiting objects. for example my_split([1,2,4,0,5,6,7,0,2,5,1], lambda x: x == 0) would return [[1,2,4,],[5,6,7],[2,5,1]].
Regarding regular expressions, again, I wanted this for parsing. This capability is somewhat supported in nltk, where you can define regular expressions for token types for chunks. See section 7.2, subsection &quot;Tag Patterns&quot; in http://nltk.googlecode.com/svn/trunk/doc/book/ch07.html .
I just want a similar capability for lists. (as an aside, regular expression theory allows for any sequence of elements from an alphabet.)

Miki:
Thanks for the link, I wasn&#039;t aware of that.</description>
		<content:encoded><![CDATA[<p>General note:<br />
For those wishing to write code in the comments, enclose your code within a [ python ] and [ / python ] block (just without the spaces :).</p>
<p>Bobby:<br />
Of course, and indeed I wrote up a few of those and put them in my standard utilities import, which by now has grown quite a bit. By the way, instead of izip with count, why not just use enumerate?</p>
<p>Dave:<br />
I disagree, although you are partially correct. Indeed when I thought of find and rfind what I had in mind was looking for a single element&#8217;s position (a bit like C&#8217;s strchr()). Consider:<br />
[python]<br />
def rfind(some_list, criterion, start_pos=None):<br />
    if start_pos is None:<br />
        start_pos = len(some_list)-1<br />
    for idx in range(start_pos, -1, -1):<br />
        if criterion(some_list[idx]):<br />
            return idx<br />
    return None<br />
[/python]</p>
<p>Now, I admit I wanted these functions mostly for some ad-hoc parsing. Still, it would be nice to split a list on token types, or other delimiting objects. for example my_split([1,2,4,0,5,6,7,0,2,5,1], lambda x: x == 0) would return [[1,2,4,],[5,6,7],[2,5,1]].<br />
Regarding regular expressions, again, I wanted this for parsing. This capability is somewhat supported in nltk, where you can define regular expressions for token types for chunks. See section 7.2, subsection &#8220;Tag Patterns&#8221; in <a href="http://nltk.googlecode.com/svn/trunk/doc/book/ch07.html" rel="nofollow">http://nltk.googlecode.com/svn/trunk/doc/book/ch07.html</a> .<br />
I just want a similar capability for lists. (as an aside, regular expression theory allows for any sequence of elements from an alphabet.)</p>
<p>Miki:<br />
Thanks for the link, I wasn&#8217;t aware of that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Miki</title>
		<link>http://www.algorithm.co.il/blogs/programming/a-python-rant/#comment-171</link>
		<dc:creator>Miki</dc:creator>
		<pubDate>Tue, 03 Mar 2009 16:27:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=197#comment-171</guid>
		<description>See http://bugs.python.org/issue4356 for a discussion on bisect module</description>
		<content:encoded><![CDATA[<p>See <a href="http://bugs.python.org/issue4356" rel="nofollow">http://bugs.python.org/issue4356</a> for a discussion on bisect module</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.algorithm.co.il/blogs/programming/a-python-rant/#comment-170</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Tue, 03 Mar 2009 15:49:10 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=197#comment-170</guid>
		<description>List is a more generic sequence than a String, which is why those methods don&#039;t apply.

A String is a sequence of characters while a List is a sequence of objects.   The concept of find() assumes a (sub)string comparison.   That isn&#039;t possible with a List, which may contain ints, floats, object instances, etc.     However, if you know your list is all strings (or sequences)...

def find( alist, pattern):
    return [x in alist if pattern in x][0]

def rfind( alist, pattern):
    return [x in alist.reverse() if pattern in x][0]

you can replace the if clause with your custom function, as needed.

As for split(), the list is already delimited by it&#039;s elementization, so....I&#039;m not sure what you&#039;re trying to do.

As for regex&#039;s, are you regex&#039;ing across the entire list?   If so, do a .join() then apply the regex.   If you are appling the regex to the elements in a list, then iterate it and apply the regex.</description>
		<content:encoded><![CDATA[<p>List is a more generic sequence than a String, which is why those methods don&#8217;t apply.</p>
<p>A String is a sequence of characters while a List is a sequence of objects.   The concept of find() assumes a (sub)string comparison.   That isn&#8217;t possible with a List, which may contain ints, floats, object instances, etc.     However, if you know your list is all strings (or sequences)&#8230;</p>
<p>def find( alist, pattern):<br />
    return [x in alist if pattern in x][0]</p>
<p>def rfind( alist, pattern):<br />
    return [x in alist.reverse() if pattern in x][0]</p>
<p>you can replace the if clause with your custom function, as needed.</p>
<p>As for split(), the list is already delimited by it&#8217;s elementization, so&#8230;.I&#8217;m not sure what you&#8217;re trying to do.</p>
<p>As for regex&#8217;s, are you regex&#8217;ing across the entire list?   If so, do a .join() then apply the regex.   If you are appling the regex to the elements in a list, then iterate it and apply the regex.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bobby</title>
		<link>http://www.algorithm.co.il/blogs/programming/a-python-rant/#comment-169</link>
		<dc:creator>Bobby</dc:creator>
		<pubDate>Tue, 03 Mar 2009 15:04:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=197#comment-169</guid>
		<description>Looks like the whitespace got eaten in the comment.  Should be pretty easy to figure out though.</description>
		<content:encoded><![CDATA[<p>Looks like the whitespace got eaten in the comment.  Should be pretty easy to figure out though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bobby</title>
		<link>http://www.algorithm.co.il/blogs/programming/a-python-rant/#comment-168</link>
		<dc:creator>Bobby</dc:creator>
		<pubDate>Tue, 03 Mar 2009 15:03:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.algorithm.co.il/blogs/?p=197#comment-168</guid>
		<description>Some of these are pretty trivial to roll your own.  A generic find() for a list, for example:

from itertools import count, ifilter, izip
def list_find(L, func):
    for i,d in ifilter(lambda x: func(x[1]), izip(count(), L)):
        return i
    return -1</description>
		<content:encoded><![CDATA[<p>Some of these are pretty trivial to roll your own.  A generic find() for a list, for example:</p>
<p>from itertools import count, ifilter, izip<br />
def list_find(L, func):<br />
    for i,d in ifilter(lambda x: func(x[1]), izip(count(), L)):<br />
        return i<br />
    return -1</p>
]]></content:encoded>
	</item>
</channel>
</rss>

