reduce to be removed?
robert.kern at gmail.com
Sun Nov 12 03:55:00 CET 2006
> Robert Kern wrote:
>> Dustan wrote:
>>> Fredrik Lundh wrote:
>>>> if you care about writing robust code, why not just use a for-loop,
>>>> and the list extend method?
>>> Because I'm embedding this expression in a list comprehension (as I
>>> stated in my original post), and last time I checked, it's not possible
>>> to treat a for-loop as an expression (which is what a list
>>> comprehension requires).
>> As with all such things, you stick the implementation in a well-named function
>> and simply call the function everywhere. The implementation never needs to be a
>> one-liner expression.
> It's already in a function, but in order to convert the reduce function
> into a for-loop that I can use as an expression, I would have to create
> another independent function, which would make that code more cluttered
> than it already is.
> Unless you're saying to perform the list comprehension manually. That
> would be two for-loops I use in the list comprehension, plus another
> one to take place of the reduce function. Sure, that spreads out each
> individual step a little more, but it also makes it more difficult to
> understand what the overall goal of the code is (I'm going for
> readability as well as easy maintenance here).
Let's just say that we disagree entirely on what constitutes readability and
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list