On Jan 31, 2020, at 11:01 AM, Soni L. <fakedme...@gmail.com> wrote:
> 
> Consider:
> 
> x=nameof(foo.bar)
> 
> in today's python becomes:
> 
> foo.bar
> x="bar"
> 
> and when running this you get an AttributeError or something.
> 
> the benefit is that "bar" is only typed once, and the attribute access (and 
> thus error-raising code) is tied to the resulting string. either you change 
> both the attribute access *and* the resulting string, or you get an error. 
> (correct me if I'm wrong.)
> 
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, as if foo doesn’t have a bar 
attribute it needs to raise an error instead.
_______________________________________________
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/NKRZ4POX6RUODA32RBWYNATMXR6W6OM5/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to