map, index
Luis Quesada
l.quesada at 4c.ucc.ie
Sun Mar 28 18:14:31 EDT 2010
Paul Rubin wrote:
> Luis Quesada <l.quesada at 4c.ucc.ie> writes:
>>> [ id*v for id,v in enumerate(L) ]
>> Cool! Thanks!
>
> If you really want to write that in pointfree style (untested):
>
> import itertools, operator
> ...
> itertools.starmap(operator.mul, enumerate(L))
>
> For your other question, you could probably do something ugly
> with ifilter, but it's not worth it.
>
> For the style of programming you're interested in, you should read the
> docs for the itertools module. Python culture in general tends to
> not be that fond of heavy use of HOF's, since it's very easy to make
> mistakes with its iterator protocol and with its dynamic type system.
Thanks a lot for the pointer.
Python is rather cool indeed.
Cheers,
Luis
More information about the Python-list
mailing list