Require parameters to be passed as keyword arguments for long funciton signatures.
See original GitHub issueWhat is wrong?
There are lots of places in the codebase with either classes or functions which take 6+ parameters. In these cases, calling these using positional arguments can be both error prone as well as hard to read.
- Errors arise when arguments are accidentally called in the wrong order.
- Difficult readability comes when it’s not clear what each parameter actually means since sometimes multiple parameters might be called with the same constant value
f(b'', b'')
.
How can it be fixed
https://www.python.org/dev/peps/pep-3102/
PEP3102 introduces a new syntax for requiring certain arguments to be called as keyword arguments. I propose changing as many of the functions as seems appropriate to this format.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Four Types of Parameters and Two Types of Arguments in ...
We can use all 4 types of parameters in one function. Of course, there are some enforced rules. Since the keyword variable-length parameter...
Read more >Using Python Optional Arguments When Defining Functions
You can also pass required and optional arguments into a function as keyword arguments. Keyword arguments can also be referred to as named...
Read more >Code Style - The Hitchhiker's Guide to Python - Read the Docs
When a function has more than two or three positional parameters, its signature is more difficult to remember and using keyword arguments with...
Read more >Forced naming of parameters in Python - Stack Overflow
Parameters after “*” or “*identifier” are keyword-only parameters and may only be passed used keyword arguments. >>> def foo(pos, *, forcenamed): ... print ......
Read more >5 Types of Arguments in Python Function Definitions
Actual parameters(arguments) are passed during a function call. ... Functions can also be called using keyword arguments of the form ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is what I got from a
git grep
. I didn’t find 7 but only six functions with 6 or more argumentsAre these the functions that you had in mind @pipermerriam ? Can I work on this?
closed by #1368