On Sun, Oct 24, 2021 at 3:43 PM Steven D'Aprano <st...@pearwood.info> wrote: > So far, I dislike all of those syntaxes (regardless of which symbol is > used as the modifier). They are all predicated on the idea that this is > a new sort of assignment, which I think is the wrong way to think about > it. I think that the better way to think about it is one of the > following: > > 1. It's not the assignment that is different, it is the expression > being bound. > > 2. It is not the assignment that is different, it is the parameter.
Or 3. It is not the assignment that is different, just when it occurs. > Suggestion #2 is, I will argue, the most natural way to think about > this. It is the parameter that differs: some parameters use early > binding, and some use late binding. Binding is binding, regardless of > when it is performed. When we do late binding manually, we don't do > this: > > if param is None: > param ?= expression # Look, it's LATE BINDING assignment!!! That's because, by the time you can even think about doing that, ANY assignment is that. So it's a plain equals sign. > - No matter how ludicrously confusing the annotation or expression > gets, the @ modifier still stands out and is obvious. I dispute the value of this. It shouldn't stand out that much, because ultimately, it is still defining an optional parameter and giving it a default value. > Here's a trivial advantage: with the "modify the equals sign" syntax, if > you decide to copy the assignment outside of the function signature, you > are left with a syntax error: > > def function(param?=expression) > # double-click on "param", drag to expression, copy and paste > > param?=expression # SyntaxError Yes, but that's true of many things, including dict display, and even assignment expressions. > Disadvantages: > > - Maybe "at symbol" is clunkier to talk about than "arrow operator" or > "reverse walrus"? > > - Search engines aren't really great at searching for the at symbol: > > https://www.google.com.au/search?q=python+what+does+%40+mean > > https://duckduckgo.com/?q=python+what+does+%40+mean > > DDG gives the top hit a Quora post about the at symbol, but everything > else is a miss; Google is even worse. But then any other symbol is going > to be subject to the same problem. Searching "python at sign" gives some good results, but the other problem with searching for symbols is that they're used in multiple ways. Ultimately, you won't get what you want by just searching for individual characters. Short of inventing a new language keyword, I don't think we're going to solve that. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/5ZVOCUGF2Q3TUJCRZZX54ATBP7PIKBZM/ Code of Conduct: http://python.org/psf/codeofconduct/