Is there any elegant and easy way to trace all the call stacks in Python of a library for debugging or code understanding purposes?
Suppose there is a very big huge library that I'm importing and need to understand the code of it.
from xyz import tokenizer
start_call_stack_trace()
tokenizer.tokenize('Hello World', some_parameter='some_value')
stop_call_stack_trace()
Now I want to get a list of all the functions with parameter values & return values (if possible!) that were called in a chain while invoking tokenizer.tokenize().
I was wondering if there is any elegant way to get it and understand the code of XYZ library quickly?
I believe, you can use Python's in-built module -
trace, It helps you trace function calls, exceptions, returns, line-by-line execution.For Example -
You can refer to this