Lele Gaifax schreef op 6/04/2017 20:07:
Piet van Oostrum <pie...@pietvanoostrum.com> writes:
It is a poor man's 'let'. It would be nice if python had a real 'let'
construction. Or for example:
[(tmp, tmp + 1) for x in data with tmp = expensive_calculation(x)]
Alas!
It would be nice indeed!
Or even
[(tmp, tmp + 1) for x in data
with expensive_calculation(x) as tmp
if tmp is not None]
Perhaps this:
[(tmp, tmp + 1) for tmp in
(expensive_calculation(x) for x in data)
if tmp is not None]
A bit less elegant, but works right now.
--
Roel Schroeven
--
https://mail.python.org/mailman/listinfo/python-list