
On Wed, Oct 27, 2021 at 10:27 AM Christopher Barker <pythonchb@gmail.com> wrote:
I'm very confused about the apparent convergence on the token "=>" for deferred parameter assignment.
The current text of the PEP uses that. It's not particularly important to me *what* symbol is used, so I just use the same one as in the PEP, for some measure of consistency.
On the other hand, others have suggested :=, which is could also be used as part of the expression, so not a good idea either :-(
Yes. I originally was positing =: and another viable suggestion is ?=. There are a few other options listed in the PEP, and I'm happy to hear arguments for and against.
BTW: was it intentional that this:
In [8]: def fun(x, y=(z:=3)): ...: print(x,y,z) ...: ...:
adds z to the function namespace -- sure seems odd to me.
If it doesn't add it to the function namespace, what does it add it to? Do parameters get their own namespace? You can reassign your parameters in the function without a nonlocal declaration, which strongly suggests that they're in the exact same namespace as assignments made in the function body; so I don't see any particular reason to isolate this one example. Of course, this wouldn't be *good* code, but it should be acceptable by the interpreter. (For starters, it will only assign z if y is omitted.) ChrisA