*Correction: Above code should read:
outputs = []
state = initial_state
for inp in inputs:
out, state = my_update_func(inp, state)
outputs.append(out)
On Sun, May 13, 2018 at 11:21 AM, Peter O'Connor wrote: target := expr
expr as target
expr -> target
target given target = expr
let target = expr
: target expr ; Although in general "target:=exp" seems the most palatable of these to me,
there is one nice benefit to the "given" syntax: Suppose you have a comprehension wherein you want to pass forward an
internal "state" between iterations, but not return it as the output: In today's python, you'd to: outputs = []
state = initial_state
for inp in inputs:
out, state = my_update_func(state)
outputs.append(state) This could not be neatly compacted into: state = initial_state
outputs = [out given out, state = my_update_func(inp, state) for inp
in inputs] Or maybe: outputs = [out given out, state = my_update_func(inp, state) for inp
in inputs given state=initial_state] Though I agree for the much more common case of assigning a value inline
"x given x=y" seems messily redundant. On Sat, May 12, 2018 at 10:37 PM, Stephen J. Turnbull <
turnbull.stephen.fw@u.tsukuba.ac.jp> wrote: David Mertz writes: Only the BDFL has a vote with non-zero weight. "Infinitesimal" != "zero". Pedantically yours, _______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/