Why does sorted()'s key parameter require a keyword argument
Question: If you inspect the signature of Python's built-in `sorted()` function like
this:

    
    
    import inspect
    print(inspect.signature(sorted))
    

The signature is: `(iterable, key=None, reverse=False)`.

Based on my understanding of positional and optional arguments acquired
[here](https://docs.python.org/3/tutorial/controlflow.html#keyword-arguments),
it would seem like you could provide an `iterable` argument and then a `key`
argument without needing a keyword `key=` for the `key` argument. But you
always need to specify `key=` when passing a `key` argument. Why is that?

I understand that if you wanted to specify `reverse=True`, but without any
`key` argument, you'd need a keyword for that, but I don't understand why
you'd need to specify `key=` when you're providing a `key`.


Answer: This is [Python issue 26729](https://bugs.python.org/issue26729), an error in
`sorted.__text_signature__`, which is missing the `/` and `*` required to
indicate that `iterable` is positional-only and `key` and `reverse` are
keyword-only. The patch is in patch review, assigned to Raymond Hettinger.
Once the patched version is released, the signature should display as

    
    
    (iterable, /, *, key=None, reverse=False)
    

