On 13/09/2023 17:21, MRAB wrote:
I think the point is to have an equivalent to C#'s 'nameof'.

It would be evaluated at compile time to a string, but with the advantage that it's clear that it's a name and not some random string that just happens to look like a name.

I'd like to draw attention to this as the first contribution to the thread that has given a precise meaning to the initial idea. It tells us both what it means and why you might want it (at least if the OP agrees). It seems to be being overlooked.

As others have amply demonstrated (short of proof, I know) what is being asked is not possible with the information available at run-time. You can't reliable get from the "reference", which is actually an expression, to the text of the expression.

The parallel with f-string = is helpful, for which compile-time support is essential, of course.

--

Jeff Allen
_______________________________________________
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/45P4HD5LBNDCPUGRRWWDV6XGR6H3GCDB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to