
On Mon, Oct 25, 2021 at 02:59:02PM +0100, Barry Scott wrote:
def func(@y=x+1, @x=0):
Is it unreasonable to get a UnboundLocal or SyntaxError for this case?
I think that UnboundLocalError is fine, if the caller doesn't supply x. So all of these cases will succeed: func(21, 20) func(21, x=20) func(y=21, x=20) func(x=20, y=21) func(x=20) and I think that the only[1] case that fails is: func() An UnboundLocalError here is perfectly fine. That error is conceptually the same as this: def func(): y = x + 1 x = 0 and we don't try to make that a syntax error. [1] To be pedantic, there are other cases like func(x=20, x=20) and func(1, 2, 3, 4) that also fail. But you knew what I meant :-) -- Steve