[Python-ideas] Proposal for an inplace else (?=) operator

Anders Hovmöller boxed at killingar.net
Sat Sep 22 08:57:15 EDT 2018

> If Python were going to address this problem, I think it better to do something like:
>          def teleport(from, to, hitchiker => Fly(), accessory => Towel(hitchhiker)):
>              etc.
> Where => specifies an expression thst is evaluated inside the function and Is approximately equivalent to your code except it works even if the caller passes None. (I don't know what the right syntax for this would be. I just picked => as something that is suggestive, not legal today and isn't ?= to avoid confusion with your proposal.)

I was gonna reply pretty much exactly this! I was gonna suggest this syntax:

def foo(a=new {}):

Which is a bit more explicit I think, but smells a bit C++.

/ Anders

More information about the Python-ideas mailing list