Difference and meaning
TL;DR: * enforces keywords, key=value, arguments passing.
min(iterable, *[, key, default])
You can read above as min
takes iterable as required
and first argument, and key and default as optional arguments
, meaning you don’t have to pass them, that needs to be passed as key=value
pairs. The * forces you to do that. So you cannot pass key
or default
without clearly stating that it is key or default or both you wish to pass. E.g. min([1,2,3])
, min({'a','b'}, key=somekey)
min(iterable, key, default)
Here we mean min
takes iterable, key, and default as required arguments
. The position of the argument matters as the first is iterable, second key and third default unless you pass them as key=words arguments e.g min(default=somedefault, iterable=(1,2,3), key=somekey)
,min([1, 3], default=x, key=y)
. But all three arguments must be passed. As you can see the second can be messy while the first is cleaner.