Re:Composing Programs – Python 3 in the tradition of SICP
by BWStearns on Sunday April 10, 2016 @04:37PM
(#11468049)
100% agree that lambdas fight python's aesthetics. On the expression complexity front I can definitely say it's easy to slowly increase their complexity until they're no longer readable. As a side note, comprehensions in Python (2 at least, not sure about 3) leak scope a bit which can lead to some really funky bugs if you're in a loop and absentmindedly use a loop variable in a comprehension.
[ Parent
| on HN ]
Re:Composing Programs – Python 3 in the tradition of SICP
by sago on Sunday April 10, 2016 @11:11PM
(#11469403)
Yes, that was a pain. Particularly because it was only true of list comprehensions, not dict comprehensions or generators:
Python 2.7.10 ...
>>> a = 3
>>> [a for a in range(10)]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> a
9
>>> a = 3
>>> list(a for a in range(10))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> a
3
Guido called it Python's 'dirty little secret'. It is fixed in Py3 though.