This is a general question, but maybe there is some obvious solution I've missed.

When I am writing code, I have a main script that calls functions in another .py file. When there is a bug or crash in the main script, in IPython I can just start typing the names of variables etc. to see what they contained at the point where the script crashed.

However, if the bug is in a function I've called from the main script, the crash dialog will indicate the function, line of code, etc. where the crash occurred. However, the only variables I can access at the IPython prompt are those used in the main script.

Is there any way to access the variables in those sub-functions after a crash, in IPython or something similar? The only other option is pasting all the code from each function into the IPython manually, or adding print lines throughout the relevant sub-functions. This is doable but extremely tedious when the crash occurred 5 functions deep, or at some unknown point within a for loop.

Any help much appreciated!

Cheers!
Nick


--
====================================================
Nicholas J. Matzke
Ph.D. student, Graduate Student Researcher
Huelsenbeck Lab
Center for Theoretical Evolutionary Genomics
4151 VLSB (Valley Life Sciences Building)
Department of Integrative Biology
University of California, Berkeley

Lab websites:
http://ib.berkeley.edu/people/lab_detail.php?lab=54
http://fisher.berkeley.edu/cteg/hlab.html
Dept. personal page: http://ib.berkeley.edu/people/students/person_detail.php?person=370
Lab personal page: http://fisher.berkeley.edu/cteg/members/matzke.html
Lab phone: 510-643-6299
Dept. fax: 510-643-6264
Cell phone: 510-301-0179
Email: mat...@berkeley.edu

Mailing address:
Department of Integrative Biology
3060 VLSB #3140
Berkeley, CA 94720-3140

-----------------------------------------------------
"[W]hen people thought the earth was flat, they were wrong. When people thought the earth was spherical, they were wrong. But if you think that thinking the earth is spherical is just as wrong as thinking the earth is flat, then your view is wronger than both of them put together."

Isaac Asimov (1989). "The Relativity of Wrong." The Skeptical Inquirer, 14(1), 35-44. Fall 1989.
http://chem.tufts.edu/AnswersInScience/RelativityofWrong.htm
====================================================
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to