On Sun, Apr 19, 2020, 7:24 AM Richard Damon <rich...@damon-family.org>
wrote:

> One of the key motivations of this proposal is to make nicer a call with a
> lot of key word arguments where the local variable name happens
> (intentionally) to match the keyword parameter name.


I think Stephen said that this "same name across scopes" is an
anti-pattern. I mostly disagree, though obviously agree that it varies
between different code. He mentioned something like:

    process_account(name=name, email=email)

And that would be better with email_john and email_jane as names in outer
scope.

I've worked with large code bases where the equivalent complex object is
used in many places. Not necessarily as a continuous life of an actual
object, but sometimes sent as JSON, other times read from database, other
times calculated dynamically, etc.

For example, maybe there is a 'person_record' that has as
attributes/keys/whatever name and email. But in this existing code, a
different name is used through a call chain and in different corners of the
code. E.g. we read json_record, which calls something naming it
dynamic_record, which eventually arrives at a function that saves
db_record. But these are all actually the same object layout or even the
same object.

When it comes time to refactor—now we need to rename 'telephone' as
'home_phone' and add 'cell_phone'—finding all the locations to change is a
PITA. If only we could grep 'person_record' globally, it would have been
easy.
_______________________________________________
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/XVI3TE6BMQJUD2IV2FDS4QUGHK35PWER/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to