Binding expressions are debugger-friendly in that they _don't_ just vanish without a trace. It's their purpose to _capture_ the values of the expressions they name. Indeed, you may want to add them all over the place inside expressions, never intending to use the names, just so that you can see otherwise-ephemeral intra-expression results in your debugger ;-)
[Steven D'Aprano firstname.lastname@example.org] wrote:
That's a fantastic point and I'm surprised nobody has thought of it until now (that I've seen).
Chris, if you're still reading this and aren't yet heartedly sick and tired of the PEP wink this ought to go in as another motivating point.
You know, I thought I was joking when I wrote that - but after I sent it I realized I wasn't ;-)
It would actually be quite convenient, and far less error-prone, to add a binding construct inside a complicated expression for purposes of running under a debugger. The alternative is typing the sub-expression(s) of interest by hand at the debugger prompt, or adding print()s, both of which are prone to introducing typos, or changing results radically due to triggering side effects in the code invoked by the duplicated sub-expression(s). Adding a binding construct wouldn't change anything about how the code worked (apart from possibly clobbering a local name).