2 Jun
2020
2 Jun
'20
3:52 a.m.
On 26/05/2020 07:09, Greg Ewing wrote:
Wild idea: Instead of sentinels, have a way of declaring optional arguments with no default, and a way of conditionally assigning a value to them if they are not bound.
E.g.
def order(eggs = 4, spam =): spam ?= Spam()
Here the '?=' means "if spam is not bound, then evaluate the rhs and assign it, otherwise do nothing."
If you're prepared to propose that (whether wild or not), why not go further (as the OP suggested as far as I recall) and allow the more concise def order(eggs = 4, spam ?= Spam()): etc.