|
|
Subscribe / Log in / New account

Positional-only parameters for Python

Positional-only parameters for Python

Posted Apr 11, 2019 2:11 UTC (Thu) by k8to (guest, #15413)
In reply to: Positional-only parameters for Python by quotemstr
Parent article: Positional-only parameters for Python

It seems valuable to have a choice on whether to expose the names or not. However, there are many modules where the docs don't talk about the argument names, but keyword arguments make the consuming code vastly more readable.

I think the fact that the arg names are exposed by default is essentially a good accident that forces interfaces to be a bit more usable than they are by default.

Amusingly I went to a good deal of trouble in some code I made to make the args keyword-only without making the implementation of the callsites harder to read. I had explicit documentation of how calls were required to be made, but used inspection to enforce it. I could used def func(**kwargs) but manually coding all the dispatch would have been really unfortunate.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds