In Python, determine if a function calls another function
问题 How can I determine programmatically if one function calls another function? I cannot modify either function. Here's what I want ( source_calls_target ): >>> def check(): >>> pass >>> def test_check(): >>> check() >>> def source_calls_target(source, target): >>> # if source() calls target() somewhere, return True >>> ??? >>> source_calls_target(test_check, check) True >>> source_calls_target(check, test_check) False Ideally, I do not want to actually call target() . Ideally, I want to check