Greg Ewing writes: > 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.
After reading the thread where it was first mentioned (on what, I now forget; I guess it was a PEP 572 precursor discussion?), I cannot unsee the "variable for variable in singleton" initialization idiom. YMMV, of course. That's just my experience. > 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" Of course that hint was welcome, and hand to scalp motion was initiated. But then I "got it" and scratched my dog's head instead of my own. :-) Could we find a better syntax to express this? Probably, but none of the ones I've seen so far (including PEP 572) grab me and make my heart throb. Is this TOOWTDI? Not yet, and maybe never. But for now it works. Steve _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/