If you verify the signature of an inline function sorted()of a Python function as follows:
import inspect
print(inspect.signature(sorted))
Signature: (iterable, key=None, reverse=False).
Based on my understanding of the positional and optional arguments obtained here , it would seem that you could provide an argument iterable, and then a keywithout using a keyword key=for the argument key. But when passing an argument, keyyou always need to specify key=. Why is this?
I understand that if you want to specify reverse=True, but without an argument key, you will need a keyword for this, but I do not understand why you need to indicate key=when you are.
user4694244
source
share