On 1/21/20 1:42 PM, Johan Vergeer wrote:
     def __repr__(self):
         return f"{nameof(Person)}({nameof(self.name)}: {self.name}, 
{nameof(self.age)}: {self.age})"


I'm trying to understand what you are looking for.  Why isn't the above line just:

   return f"Person(name: {self.name}, age: {self.age})"

That is, instead of "{nameof(self.name)}" just use "name"?  You had to type "name" in your string anyway.  How would nameof be helping here?

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

Reply via email to