[Python-Dev] Keyword-only parameters (original) (raw)

Larry Hastings larry at hastings.org
Tue Apr 14 21:40:32 CEST 2015


On 04/14/2015 01:40 PM, Eric V. Smith wrote:

I'm working on adding a numericowner 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 "numericowner=True" would be a better usage.

Boolean parameters are the classic problem that keyword-only parameters solve. It forces the caller to provide context for the parameter, solving the mystery-meat API problem of

tarfile.extractall(".", None, True)

On 04/14/2015 01:56 PM, Paul Sokolovsky wrote:

But newer parts of stdlib, e.g. asyncio, visibly overuse kw-only args.

Overuse? asyncio? You mean "that thing Guido just wrote last year"?
The most practical definition I've heard for the word "pythonic" is "code like Guido writes".

//arry/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150414/28901fe3/attachment.html>



More information about the Python-Dev mailing list