Re:Unpythonic Python
by loqi on Wednesday April 09, 2014 @06:51PM
(#7563063)
In the generator case you can define a poor man's let like this:
And use it by "iterating":
Still not as nice as having actual syntax for it.
[ Parent
| on HN ]
Re:Unpythonic Python
by piinbinary on Wednesday April 09, 2014 @07:00PM
(#7563103)
You can also hack the with statement to get a let block:
import contextlib
@contextlib.contextmanager
def let(*values):
yield values
with let(1, 2, 3) as (a, b, c):
print(a, b, c)