On Sun, Apr 19, 2020 at 06:06:50PM +0200, Alex Hall wrote:
> >
> > >> function(*, dunder, invert, private, meta, ignorecase)
> > >>
> > >
> > >
> > > No reader will ever have to think about the difference. They will simply
> > > see the second version and know which arguments are being passed.
> >
> > I seem to be immune to this magical knowledge.
> >
>
> Sorry, what? How is there any doubt that the arguments being passed are
> dunder, invert, private, meta, and ignorecase? They're right there.
That tells us the meaning of the arguments in the *caller's* context.
It doesn't tell us the meaning of the arguments in the *callee's*
context, which is critical information. There is a huge difference
between these:
process_files(delete=obsolete_files, archive=irrelevent_files)
process_files(archive=obsolete_files, delete=irrelevent_files)
even though both calls receive the same arguments, so it is critical to
know the callee's context, i.e. the parameters those arguments get
bound to.
> Now, which parameters those arguments are bound to is less obvious, but:
>
>
> 1. When you read the function call, you're thinking about the arguments,
> not the parameters. You can see which information goes into the function,
> and the first question you should ask yourself is 'is that the right
> information?'.
And the only way to know that is to think about the parameters. I trust
that you will agree that we should care about the difference between
(let's say):
pow(8, 2) # 64
pow(2, 8) # 256
and that it's critical to match the arguments to the parameters in the
right order or you will get the wrong answer.
I can't tell you how many times I messed up list.insert() calls because
I got the arguments in the wrong order.
So for the reader who doesn't know what this star argument `*` does, it
is not enough for them to say "Oh that's fine then, we're passing the
right arguments, it doesn't matter what parameters they get matched to".
The parameters are absolutely critical.
--
Steven
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/BRMV32XDSC2UFVCCCYTRULE53FWMAUKO/
Code of Conduct: http://python.org/psf/codeofconduct/