<div><br><div><br><div class="gmail_quote">On Mon, Sep 12, 2011 at 10:04 PM, rantingrick <span dir="ltr"><<a href="mailto:rantingrick@gmail.com">rantingrick@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
############################################################<br>
#                          Quote                           #<br>
############################################################<br>
# The itertools module is great HOWEVER i believe most     #<br>
# people are recreating the functionalities due to the     #<br>
# insanely cryptic and/or missing examples from each       #<br>
# method                                                   #<br>
############################################################<br>
<br>
py> print itertools.chain.__doc__<br>
chain(*iterables) --> chain object<br>
Return a chain object whose .next() method returns elements from the<br>
first iterable until it is exhausted, then elements from the next<br>
iterable, until all of the iterables are exhausted.<br>
<br>
############################################################<br>
#                          Quote                           #<br>
############################################################<br>
# Okay not TOO bad however this simple example would       #<br>
# suffice:                                                 #<br>
############################################################<br>
<br>
py> list(itertools.chain([1,2], [3,[4,5],6]))<br>
[1, 2, 3, [4, 5], 6]<br>
<br>
############################################################<br>
#                          Quote                           #<br>
############################################################<br>
# Same for these...                                        #<br>
############################################################<br>
<br>
py> ''.join(list(itertools.dropwhile(lambda x:x==" ", "    hello<br>
word    ")))<br>
'hello word    '<br>
py> ''.join(list(itertools.takewhile(lambda x:x==" ", "    hello<br>
word    ")))<br>
'    '<br>
py> print itertools.compress.__doc__<br>
compress(data, selectors) --> iterator over selected data<br>
Return data elements corresponding to true selector elements.<br>
Forms a shorter iterator from selected data elements using the<br>
selectors to choose the data elements.<br>
<br>
############################################################<br>
#                          Quote                           #<br>
############################################################<br>
# WTF! Would you like to define a Python "selector". Could #<br>
# it be that we should be using "selector function" or     #<br>
# "predicate function" instead?                            #<br>
############################################################<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a></font></blockquote><div><br></div><meta http-equiv="content-type" content="text/html; charset=utf-8">I'm honestly missing the point of this mail.<div>
<br></div><div>Can you elaborate? </div></div><br></div></div>