Is there any way to know if the value of an argument is the default vs. user-specified?
问题 I'm looking for something that works like Lisp's arg-supplied-p variables, to help differentiate a default value from the same value specified by a user. Example: def foo(a=10): pass I'd like to know in foo if it was called like this: foo() or like this: foo(10) or even like this: foo(a=10) The last 2 are synonymous enough to me; I don't need to know that detail. I've looked through the inspect module a bit, but getargspec returns exactly the same results for all 3 calls. 回答1: Except for