
Oct. 25, 2021
6:22 a.m.
On Sun, Oct 24, 2021 at 05:40:55PM +0100, Jonathan Fine wrote:
Please forgive me if it's not already been considered. Is the following valid syntax, and if so what's the semantics? Here it is:
def puzzle(*, a=>b+1, b=>a+1): return a, b
We can consider that to be syntactic sugar for: def puzzle(*, a=None, b=None): if a is None: a = b+1 if b is None: b = a+1 So that has a perfectly sensible interpretation: - a is optional - b is optional - but you must supply at least one. and should be perfectly legal. I see no reason to prohibit it. (It would be nice if we could give a better exception, rather than just UnboundLocalError, but that's not essential.) -- Steve