
On Tue, Oct 26, 2021 at 11:44 AM Rob Cliffe via Python-ideas <python-ideas@python.org> wrote:
I prefer 1). Easier to understand and debug in examples with side-effects such as def f(a := enter_codes(), b = assign_targets(), c := unlock_missiles(), d = FIRE()): (not that this is something to be particularly encouraged).
It's worth noting that this would call the functions at different times; assign_targets and FIRE would be called when the function is defined, despite not entering the codes and unlocking the missiles until you actually call f(). The difference between early evaluation and late evaluation is that one retains the *value* and the other retains the *expression*. So it's something like: _b_default = assign_targets(); _d_default = FIRE() def f(a, b, c, d): if a is not set: a = enter_codes() if b is not set: b = _b_default if c is not set: c = unlock_missiles() if d is not set: d = _d_default ChrisA