3 ms·
> Keyword arguments are safer and more explicit/self-documenting. Keyword arguments are also more redundant (a function taking a single argument usually does n
by masklinn 8y ago
> Keyword arguments are safer and more explicit/self-documenting.
Keyword arguments are also more redundant (a function taking a single argument usually does not need that argument to be named, quite the opposite, even for some multi-parameter functions it makes no sense e.g. `max(a=1, b=2)` is downright no matter how you name the arguments)), and the lack of positional-only parameters means any old name to what was intended as a positional effectively becomes part of the API.
I think Swift has the better pick there, an argument can be either positional or named, not both, and positional-only parameters are used to great effect. Sadly Python's history of positional-or-named can't really be fixed.
- ehsankia 8y ago> a function taking a single argument usually does not need that argument to be named Would you rather have: thread_pool.shutdown(True) or thread_pool.shutdown(wait=True) Even with single argument, it's not always clear what the argument means from the function name, so being explicit makes the code more readable. EDIT: I realize you said "usually", but my point still stands.
- totalperspectiv 8y agoYou can maintain clarity with your positional arguments with just: wait = True thread_pool.shutdown(wait)
- polotics 8y agoI am sorry but this looks too much like Java to me.