Imagine I am debugging the following script:
import ipdb
def slow_function(something):
# I'm a very slow function
return something_else
def fast_function(something_else):
# There's a bug here
return final_output
something = 1
something_else = slow_function(something)
ipdb.set_trace()
final_output = fast_function(something_else)
ipdb.set_trace()
When the ipdb.set_trace()
line is met the debugger shell is prompted and I can now execute the final_output = fast_function(something_else)
statement to check whether fast_function
is behaving as intended. I see there's a bug so I go into the source code and I fix it. Now I want to see whether the fix is correct but I don't want to run the script a second time (because it's slow), nor I want to save something_else
on disk (because, maybe, it's very large).
Is there a way to update fast_function() in the debugger shell so that the new source code is used?
fast_function
, they won't be updated. So for instance if there is code somewhere that doesfrom some_module import fast_function
, orx = fast_function
, those references to the function won't be affected by changing it in the module where it was originally defined. – Ballata