
I haven’t given much thought regarding the syntax. The prefix “=“ just popped into my mind and I went along with it to use in my examples. The point was that f-strings are potentially a good place to implement such thing. By “elegant", I wasn’t talking about the syntax. It was more about the benefits of it being well integrated python construct, which is subject to a parser and is a python code by all standards and it fitting in that place sensibly given what it is. Regards, DG
On 24 Sep 2023, at 05:15, Stephen J. Turnbull <turnbull.stephen.fw@u.tsukuba.ac.jp> wrote:
Dom Grigonis writes:
Eric Smith wrote: Since I wrote that commit: no one is saying it’s impossible or overly difficult,
To be honest it is exactly what was being said.
Sure ... about an unclearly expressed early version of the proposal, that seemed to ask "given an object x, tell me the name of x". In the end, I don't think there was any disagreement that doing that reliably is indeed impossible. But if someone has written that the #nameof version of the proposal is impossible to implement, that is not representative of what most of us think or have said.
What I think is that it would be an elegant feature if it was implemented at python level.
The postfix '=' flag is elegant by anyone's standard, I think: it provides immediately useful, though limited, functionality, with no waste, and is automatically fit for purpose because it satisfies DRY. And it is mnemonic in the sense that you may have to look it up to write it, but once you've learned it, you will recognize it when you see it in unfamiliar code because it "looks like" what it produces.
The proposed prefix '=' flag is much less attractive to me on all counts above, except that it's quite mnemonic.
Steve