On Sat, Oct 30, 2021 at 6:32 PM Chris Angelico <ros...@gmail.com> wrote:

> We could just write every function with *args, **kwargs, and then do
> all argument checking inside the function. We don't do this, because
> it's the job of the function header to manage this. It's not the
> function body's job to replace placeholders with actual values when
> arguments are omitted.
>

This is actually a great point, and I don't think it' sa straw man -- a
major project I'm soaring on is highly dynamic with a lot of subclassing
with complex __init__ signatures. And due to laziness or, to be generous,
attempts to be DRY, we have a LOT of mostly *args, **kwargs
parameterizations, and the result is that an, e.g. typo in  a parameter
name doesn't get caught till the very top of the class hierarchy, and it's
REALLY hard to tell where the issue is.

(and there is literally code manipulating kwargs, like: thing =
kwargs.get('something')

I'm pushing to refactor that code somewhat to have more clearly laid out
function definitions, even if that means some repetition -- after all, we
need to document it anyway, so why not have the interpreter do some of the
checking for us?

The point is: clearly specifying what's required, what's optional, and what
the defaults are if optional, is really, really useful -- and this PEP will
add another very handy feature to that.

-CHB


-- 
Christopher Barker, PhD (Chris)

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
_______________________________________________
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/2PBO43E6HQRCAXLWAYW4223LHLKBOTET/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to