>>> Printing a fragment of the logical line is clearly not very helpful
Given the unbounded and recursive nature of 'logical line', I disagree with that as a general, versus special-case, statement.
Consider:
r(a()/b(),
d()/e(),
g=h()/i(),
)
If either e() or i() returns 0, printing all 4 lines is less helpful, by adding noise (which line has the error?), than just printing the 1 line with the ZeroDivisionError. The context is irrelevant.
Or consider:
mymegalist = {
a,
b,
... <500 lines, one item per line>
xyz,
}
If 1 of the expressions raises an error, do you really want all 500 lines in the traceback? Again, the context is probably irrelevant.
Quite aside from this, 'd()/e(),' and 'g=h()/i(),' are both legal logical lines in themselves (though with different semantics) as well as being fragments of the r call.
Moreover, the multiline r call above may itself be just a fragment of a call to another function (further indented). The practical difficulty for the proposal, even if limited to multiline calls, is that any bare call could either be part of a larger expression by returning something or be a statement operating through side-effects. Similarly, any 'var=f()' call could either be an assignment statement or keyword arg expression in some other call. |