<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Thomas,<br class=""><div><br class=""></div><div><blockquote type="cite" class=""><div class=""><div class="">If you define a function or variable at the breakpoint, it's probably making it a local variable inside main(), so it's not in scope for name().<br class=""><br class="">You may be able to get round this by defining the new function and then explicitly making it a global variable, something like this:<br class=""><br class="">globals()['print_name'] = print_name<br class=""><br class="">Not exactly elegant, but hopefully it works.<br class=""></div></div></blockquote><div><br class=""></div><div>Yes—makes sense and does the trick! I’ll have to figure out an Emacs hook to automatically update globals in that manner. My output:</div><div><br class=""></div><div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class="">In main.</div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 180, 29);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/Users/ayank/Documents/programming/python/bar.py</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">(13)</span><span style="font-variant-ligatures: no-common-ligatures; color: #2eaebb" class="">main</span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">()</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2fb41d" class="">     12 </span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class="">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #2fb41d" class="">import</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ipdb</span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">;</span><span style="font-variant-ligatures: no-common-ligatures" class=""> ipdb</span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">.</span><span style="font-variant-ligatures: no-common-ligatures" class="">set_trace</span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">()</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 180, 29);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">---> 13 </span><span style="font-variant-ligatures: no-common-ligatures; color: #b42419" class="">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #000000" class="">name</span><span style="font-variant-ligatures: no-common-ligatures; color: #400bd9" class="">()</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(47, 180, 29);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">     14 </span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2d961e" class="">ipdb> </span><span style="font-variant-ligatures: no-common-ligatures" class="">name()</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Alice</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2d961e" class="">ipdb> </span><span style="font-variant-ligatures: no-common-ligatures" class="">!def print_name(): print ("Bob")</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2d961e" class="">ipdb> </span><span style="font-variant-ligatures: no-common-ligatures" class="">name()</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Alice</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2d961e" class="">ipdb> </span><span style="font-variant-ligatures: no-common-ligatures" class="">globals()['print_name'] = print_name</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #2d961e" class="">ipdb> </span><span style="font-variant-ligatures: no-common-ligatures" class="">name()</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">Bob</span></div><div style="margin: 0px; font-stretch: normal; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(45, 150, 30);" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">ipdb> </span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div><div class="">To follow up on Wes’s comment regarding TDD—I’m writing signal processing code and using Python + SciPy like Matlab. There are some calculations when the code starts that take a few minutes. I have a breakpoint there and am experimenting with the next steps of the processing chain.</div></div></div></body></html>