[Python-Dev] Keyword-only parameters

Gregory P. Smith greg at krypto.org
Tue Apr 14 23:11:28 CEST 2015


On Tue, Apr 14, 2015 at 1:56 PM Alexander Walters <tritium-list at sdamon.com>
wrote:

> Lacking anything anyone else says... the use case for keyword only
> arguments (where they actually make the code better rather than simply
> being different) is rather limited.
>
> I disagree.  For parameters not often passed or beyond 3-4 parameters
being used on any API I actually prefer that we start using keyword only
parameters for those.

I'd say feel free to use keyword only parameters when you believe they make
sense.  Most of the stdlib does not do it because most of the APIs were
defined in the 2.x era and maintaining compatibility with them is desirable
for 2AND3 compatible code. But for new things, feel free.

-gps


> On 4/14/2015 13:40, Eric V. Smith wrote:
> > I'm working on adding a numeric_owner parameter to some tarfile methods
> > (http://bugs.python.org/issue23193),
> >
> > In a review, Berker suggested making the parameter keyword-only. I agree
> > that you'd likely never want to pass just "True", but that
> > "numeric_owner=True" would be a better usage.
> >
> > But, I don't see a lot of keyword-only parameters being added to stdlib
> > code. Is there some position we've taken on this? Barring someone saying
> > "stdlib APIs shouldn't contain keyword-only params", I'm inclined to
> > make numeric_owner keyword-only.
> >
> > Is there anything stopping me from making it keyword-only?
> >
> > Thanks.
> > Eric.
> > _______________________________________________
> > Python-Dev mailing list
> > Python-Dev at python.org
> > https://mail.python.org/mailman/listinfo/python-dev
> > Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/tritium-list%40sdamon.com
>
> _______________________________________________
> Python-Dev mailing list
> Python-Dev at python.org
> https://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> https://mail.python.org/mailman/options/python-dev/greg%40krypto.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20150414/eca2c8c0/attachment.html>


More information about the Python-Dev mailing list