[Python-ideas] Proposal: A Reduce-Map Comprehension and a "last" builtin

Greg Ewing greg.ewing at canterbury.ac.nz
Sun Apr 8 18:58:56 EDT 2018


Kyle Lahnakoski wrote:

> Consider Serhiy Storchaka's elegant solution, which I reformatted for
> readability
> 
>>smooth_signal = [
>>     average
>>    for average in [0]
>>    for x in signal
>>     for average in [(1-decay)*average + decay*x]
>>]

"Elegant" isn't the word I would use, more like "clever".
Rather too clever, IMO -- it took me some head scratching
to figure out how it does what it does.

And it would have taken even more head scratching, except
there's a clue as to *what* it's supposed to be doing:
the fact that it's assigned to something called
"smooth_signal" -- one of those "inaccurate names" that
you disparage so much. :-)

-- 
Greg


More information about the Python-ideas mailing list