On 1/02/20 6:15 am, Richard Damon wrote:
One issue I am seeing is that x = nameof(foo.bar) is crossing the
line between compile time and run time behaviors. The resultant
string, “bar” needs to be generated at compile time, but the
operation still needs to do a check at run-time to determine if that
IS the right result,

I don't think I would bother with the runtime check. This is
mostly going to be used in a context where you're writing out
the same thing again to get its value, e.g.

   print("The value of", nameof(foo.bar), "is", foo.bar)

This can be translated to

   print("The value of", "bar", "is", foo.bar)

and you'll still get an AttributeError if foo doesn't have
a bar attribute.

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

Reply via email to