PyWart: Itertools module needs attention

Nick Stinemates nstinemates at gmail.com
Mon Sep 12 18:25:49 EDT 2011


On Mon, Sep 12, 2011 at 10:04 PM, rantingrick <rantingrick at gmail.com> wrote:

>
> ############################################################
> #                          Quote                           #
> ############################################################
> # The itertools module is great HOWEVER i believe most     #
> # people are recreating the functionalities due to the     #
> # insanely cryptic and/or missing examples from each       #
> # method                                                   #
> ############################################################
>
> py> print itertools.chain.__doc__
> chain(*iterables) --> chain object
> Return a chain object whose .next() method returns elements from the
> first iterable until it is exhausted, then elements from the next
> iterable, until all of the iterables are exhausted.
>
> ############################################################
> #                          Quote                           #
> ############################################################
> # Okay not TOO bad however this simple example would       #
> # suffice:                                                 #
> ############################################################
>
> py> list(itertools.chain([1,2], [3,[4,5],6]))
> [1, 2, 3, [4, 5], 6]
>
> ############################################################
> #                          Quote                           #
> ############################################################
> # Same for these...                                        #
> ############################################################
>
> py> ''.join(list(itertools.dropwhile(lambda x:x==" ", "    hello
> word    ")))
> 'hello word    '
> py> ''.join(list(itertools.takewhile(lambda x:x==" ", "    hello
> word    ")))
> '    '
> py> print itertools.compress.__doc__
> compress(data, selectors) --> iterator over selected data
> Return data elements corresponding to true selector elements.
> Forms a shorter iterator from selected data elements using the
> selectors to choose the data elements.
>
> ############################################################
> #                          Quote                           #
> ############################################################
> # WTF! Would you like to define a Python "selector". Could #
> # it be that we should be using "selector function" or     #
> # "predicate function" instead?                            #
> ############################################################
> --
> http://mail.python.org/mailman/listinfo/python-list


I'm honestly missing the point of this mail.

Can you elaborate?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110912/2c6ae7fe/attachment-0001.html>


More information about the Python-list mailing list