I want to be able to investigate and trace through the Python source code to see how things work under the hood, and to resolve doubts about features that are not explicitly documented in the reference document.
I would like to have some starting information on how to go about this, because it's pretty overwhelming. I can read C, so I have that going on for me. Besides that, the task seems a little intimidating without at least a slight amount of guidance.
For example, let's say I wanted to document how attribute reference is implemented in Python. How would I go about tracing what happens when an attribute reference expression is present in a Python program?
Perhaps an overview of how the source code is organized and what each part does would be helpful, along with some "walk=thru" examples, such as the "attribute reference" case.
I searched for information on this but there doesn't seem to be much.
Perhaps a good Python debugger would help? I would try using the PyDev plugin for Eclipse. That would at least help you trace what special python methods (such as __getattr__()
or __setattr__()
) are called when you reference an attribute of a class. If you need to go deeper, you can look at the Python C API or even the Python C Source Code.
There is a trace module in the python standard library. It has several modes, and can be used to print every line of python code as it is executed like this:
python -m trace -t myscript.py
See http://docs.python.org/library/trace.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With