On Sat, 16 Sept 2023 at 19:48, Jeff Allen <ja...@farowl.co.uk> wrote:
> It needs language (parser) support because it does what you identified early 
> on: "take whatever is given and put it in quotes", where "whatever is given" 
> is the text of the expression only available at run-time.
>

I didn't say "and put it in quotes". I said "return the text string unchanged".

This is, fundamentally, a problem of an editing tool. Teach the tool
that a string literal inside nameof() should be parsed for variables.
This is no harder than taking the program source and parsing it for
variables - in fact, it's the exact same thing, just done a second
time.

I have done exactly this sort of parsing, using the Python ast module.
It's not difficult.

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/IRT4UNFBKPEP6U2PENVGQEAQQQ3WSBW2/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to