On Tue, May 25, 2021 at 8:11 AM Chris Angelico <ros...@gmail.com> wrote:

> On Tue, May 25, 2021 at 5:29 PM Steven D'Aprano <st...@pearwood.info>
> wrote:
> > Here's a counter-proposal: we have a special symbol which is transformed
> > at compile-time to the left hand assignment target as a string. Let's
> > say we make that special expression `@@` or the googly-eyes symbol.
>
> ...
>
> Questions:
>
> 1) Is this restricted to the "=" assignment operator, or will other
> operators trigger this too?
> x += f(@@) # ?
> if x := f(@@): # ?
>
> 2) What about other forms of assignment?
> for spam in foo(@@): # ?
> with open(@@ + ".json") as config: # ?
> from sys import @@ as argv # okay that's just stupid
>
> 3) Is this a string literal, or a magic token that happens to evaluate
> as a string?
> x = @@ ".json" # Legal if @@ is a string literal
>
> No wrong answers. (Well, unless you say "tomato". That is a very wrong
> answer to a yes/no question.)
>
> I'm liking this. It might mean that class syntax and decorator abuse
> become less necessary as ways to get around name duplication.
>
> ChrisA
>

Another one to add to the list: does it work with lambdas on the RHS? Does
it matter how nested?

x = lambda: @@
y = lambda: lambda: lambda: @@

---
Ricky.

"I've never met a Kentucky man who wasn't either thinking about going home
or actually going home." - Happy Chandler
_______________________________________________
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/ZRQIVAPVVL63BZ6EJ76CATLWJP3V55MV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to