[Tutor] questions about debugging program

gerard henry gerard.henry at free.fr
Sun Aug 17 15:44:38 EDT 2003


hello,
i have to modify a big program writen in python (python 2.3, 
pygtk-0.6.11, MySQL module..., there is 60 modules!) and i begin to 
learn python with "Learning Python" book.
I've some experience in other langages as C, C++, so i want to replace 
in actual code:
print statement
by something like:
print "%s %d" __FILE__ __LINE__ statement
as we used to do in C/C++, so i can go to the right line in the right 
file easier.
I see that i can use __name__ or __file__ for file name, but how can i 
have the line number?
I think the best thing i can do is to replace print statement by 
something like print2(statement), but it s not easy to replace lines 
because sometimes print is more comlex, perhaps i can rewrite a print() 
function? i'm sure that somathing already exists, but where?

Thanks for your help,

gerard




More information about the Tutor mailing list