How to get the python sourcecode line, when debuging the Python C sources?

John E. Davis davis at space.mit.edu
Sat Sep 11 05:58:33 EDT 1999


On 8 Sep 1999 00:49:22 GMT, Aahz Maruch <aahz at netcom.com>
wrote:
>>string containing the filename.  Adding something like "(char *)(((char
>>*)f->f_code->co_filename))+20)" to the watch window should do the trick.

It is not necessary to use the initial cast since 

     (char *)f->f_code->co_filename + 20

is already a `char *'.

>And people wonder why I think C is a dead language.

Not really.  What this expression does it actually somewhat
complicated.  For example, suppose X is some object in the python
language, e.g.,

      X = 3.0

How would you form a string from the last 3 bytes of the 8 byte object
represented by X in pure python?  In C you would use `(char *)&X + 5'.     
Why you would want to do this another issue.

--John




More information about the Python-list mailing list