
Oct. 25, 2021
5:45 p.m.
On 10/24/21 11:22 PM, Steven D'Aprano wrote:
On Sun, Oct 24, 2021 at 05:40:55PM +0100, Jonathan Fine wrote:
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.)
+1