Mouin
Mouin

Reputation: 1103

Tracingback a Python function

A way I usually use to understand a project architecture in C++ is to set a break point in a particular function using GDB, and then using the traceback feature, I can easily understand the function calls between the different classes. I am totally new to Python and I want to ask what are the best Technics used to understand the Python project,

I took a look at traceback but the problem is that it is only tracing the functions inside the same module, so if the caller is in a different module it won't be traced. Besides, the size of the stack is also limited, correct me if I am wrong.

Could you please share the Technics you are using based on your own experience.

Upvotes: 0

Views: 33

Answers (1)

bruno desthuilliers
bruno desthuilliers

Reputation: 77892

I don't know where you got the idea that python's tracebacks would be limited to a single module or limited in size - when an exception occurs, you of course have the full stack trace available.

This being said, Python has a full step debugger in it's stdlib, which lets you inspect and navigate the whole call stack. And there are of course third-part step debuggers in various IDEs and custom shells or environments (ie IPython etc).

NB the inspect module might also be of interest to you - and not only for stack inspection ;-)

Upvotes: 1

Related Questions