On Sun, Oct 31, 2021 at 3:31 PM Steven D'Aprano
>>> inspect.signature(bisect.bisect_left)
I challenge anyone to honestly say that if that signature read:
they would not be able to infer the meaning, or that Python would be a worse language if the interpreter managed the evaluation of that default so you didn't have to.
There is a downside: it is possible to flat-out lie to the interpreter, by mutating bisect_left.__defaults__, so that help() will give a completely false signature. But if you want to shoot yourself in the foot, there are already plenty of gorgeous guns available. Behold, the G3SG1 "High Seas" of footguns:
def spam(x, y, z="foo", *, count=4): ... ... def ham(a, *, n): ... ... spam.__wrapped__ = ham inspect.signature(spam)
Ahhhhh whoops. We just managed to lie to ourselves. Good job, us. ChrisA