Python Tutorial Was: Guido's regrets: filter and map

Michael Hudson mwh at python.net
Tue Nov 26 12:38:17 EST 2002


grante at visi.com (Grant Edwards) writes:

> In the case of reduce:
> 
>   sum = reduce(operator.add, valueList)
> 
> How is that expressed any better with a list comprension?

It's not.  It's better expressed as a for loop, though.  The for loop
might well be quicker, too (cue Alex proving me wrong :).

Cheers,
M.

-- 
  In many ways, it's a dull language, borrowing solid old concepts
  from many other languages & styles:  boring syntax, unsurprising
  semantics, few  automatic coercions, etc etc.  But that's one of
  the things I like about it.                 -- Tim Peters, 16 Sep 93



More information about the Python-list mailing list