<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=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">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><br><br><div class="gmail_quote"><div dir="ltr">On Thu, Sep 6, 2018 at 9:11 AM Steven D'Aprano <<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> I have a working implementation for a new syntax which would make <br>
> using keyword arguments a lot nicer. Wouldn't it be awesome if instead <br>> foo(a=a, b=b, c=c, d=3, e=e)<br>> we could just write:<br>> foo(*, a, b, c, d=3, e)<br>You say that as if consistent naming is *in and of itself* a good thing, <br>
merely because it is consistent.<br>
I'm in favour of consistent naming when it helps the code, when the <br>
names are clear and relevant. But why should I feel bad about failing to <br>
use the same names as the functions I call? </blockquote><div> </div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">Keeping medicines from the bloodstreams of the sick; food <br>from the bellies of the hungry; books from the hands of the <br>uneducated; technology from the underdeveloped; and putting <br>advocates of freedom in prisons. Intellectual property is<br>to the 21st century what the slave trade was to the 16th.<br></div></div></div>