> On 21 Jan 2020, at 22:50, Andrew Barnert via Python-ideas 
> <python-ideas@python.org> wrote:
> 
> But it seems like nameof(self.age) always has to be just “age”, which you 
> already have to type inside the nameof if you want it to be findable, so 
> it’ll never be useful. Anywhere you could write `{nameof(self.age)}` you 
> could just more simply write `age`.

That misses the point. Refactoring tools for example won't know how to handle 
the rename of the variable foo in this example:

foo = 1
n = 'foo'
print(n, foo)

If you had 

n = nameof(foo)

It would know what to do. That's why this feature exists in C# and AFAIK also 
in Swift for example. 

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

Reply via email to