itertools to iter transition (WAS: Pre-PEP: Dictionary accumulator methods)

Jack Diederich jack at performancedrivers.com
Tue Mar 29 18:48:39 EST 2005


On Tue, Mar 29, 2005 at 12:38:42PM +0300, Ville Vainio wrote:
> >>>>> "Raymond" == Raymond Hettinger <vze4rx4y at verizon.net> writes:
> 
>     Raymond> If the experience works out, then all you're left with is
>     Raymond> the trivial matter of convincing Guido that function
>     Raymond> attributes are a sure cure for the burden of typing
>     Raymond> import statements.
> 
> For one thing, it would make it harder to find the functions from the
> docs. It's easy to find the doc for 'itertools', but iter object
> methods would require browsing that infamous Chapter 2 of the
> documentation...
> 
> Apart from that, I don't really see the advantage in moving away from
> itertools.

I only use itertools when I have to currently, which isn't necessarily
bad (premature optimization etc) but I do use lists when I just need an
iterator - simply because 'list()' is easier to type than 
'^<space><home>^n^nimport itertools as it<CR>^x^x' (emacsen to mark HERE,
jump to the top, import itertools, and jump back).  If itertools methods
were handier I'd use them when I just want to iterate.  As an anecdote
I use generator comprehensions[1] more often than list comprehensions.

I'll give the builtin manipulations a try but since I have to deal with
many machines I can't promise to flex it much.

-jack

[1] aside, I didn't care too much about upgrading machines 2.2 => 2.3, but 
    when 2.4 came along with set as a builtin and generator comprehensions it
    was compelling.



More information about the Python-list mailing list