<div dir="ltr"><br><br>On Thursday, September 6, 2018 at 4:13:45 PM UTC+2, David Mertz wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr">Steven's point is the same as my impression. It's not terribly uncommon in code I write or read to use the same name for a formal parameter (whether keyword or positional) in the calling scope.  But it's also far from universal.  Almost all the time where it's not the case, it's for a very good reason.<div><br></div><div>Functions by their nature are *generic* in some sense.  That is, they allow themselves to be called from many other places.  Each of those places has its own semantic context where different names are relevant to readers of the code in that other place.  As a rule, the names used in function parameters are less specific or descriptive because they have to be neutral about that calling context.  So e.g. a toy example:</div><div><br></div><div><font face="monospace, monospace">for record in ledger:</font></div><div><font face="monospace, monospace">    if record.amount > 0:</font></div><div><font face="monospace, monospace">        bank_transaction(currency=<wbr>currencies[record.country],</font></div><div><font face="monospace, monospace">                         deposit=record.amount,</font></div><div><font face="monospace, monospace">                         account_number=<a href="http://record.id" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Frecord.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7n2pU55hFL89x42lhbV3wTuYsoQ';return true;" onclick="this.href='http://www.google.com/url?q\x3dhttp%3A%2F%2Frecord.id\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG7n2pU55hFL89x42lhbV3wTuYsoQ';return true;">record.id</a>)</font></div><div><font face="monospace, monospace"><br></font></div><div><font face="arial, helvetica, sans-serif">Once in a while the names in the two scopes align, but it would be code obfuscation to *force* them to do so (either by actual requirement or because "it's shorter").</font></div></div></blockquote><div><br></div><div>Pythons normal arguments already gives people an option to write something else "because it's shorter" though: just use positional style. So your example is a bit dishonest because it would be:</div><div><br></div><div><div><font face="monospace, monospace">        bank_transaction(currencies[record.country],</font></div><div><font face="monospace, monospace">                         record.amount,</font></div><div><font face="monospace, monospace">                         <a href="http://record.id/" target="_blank" rel="nofollow">record.id</a>)</font></div></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">...in many many or even most code bases. </font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">And I would urge you to try out my analysis tool on some large code base you have access to. I do have numbers to back up my claims. I don't have numbers on all the places where the names don't align but would be *better* if they did align though, because that's a huge manual task, but I think it's pretty obvious these places exists.</font></div><div><font face="monospace, monospace"><br></font></div></div>