
May 30, 2020
8:57 a.m.
On 30/05/20 8:03 pm, Steven D'Aprano wrote:
Is this `?=` idea for a general purpose operator we can use anywhere we like?
I introduced it as part of a two-part idea for allowing optional parameters without a default. But there would be nothing to stop you from using it elsewhere. The syntax was inspired by a similar thing in makefiles. It's entirely possible that someone else has used it for something else, though.
E.g. I do this lots of times:
try: spam except NameError: spam = expression
(Well, usually I end up using `def spam()...` but that's another story.) If we had that operator I could use:
spam ?= value
That was my idea, yes. -- Greg