Search code examples
pythonargumentssignature

Dollar sign in function __text__signature__


Input

def f(no, matter='what', *iz, **here):
    pass

f.__call__.__text_signature__

Output

'($self, /, *args, **kwargs)'

What is the $ in the signature talking about?
(I'm not obsessed with the self thing, rather a bit confused about the dollar sign appearing there)


Solution

  • The $ is an explicit marker for self and similar arguments, present to make inspect.Signature's detection of such arguments a little more robust. See Larry Hastings's message from back when he introduced this use of $, and the code in inspect.py that processes the $.