by coliveira · 3y ago · 0 comments
import code; code.interact(local=vars(foo))
where `foo` is the module object you want to set as current. This launches a subREPL in that module's namespace. (EOF kills the subREPL and returns to main.)Python has a debugger in the standard library that can also do post-mortem inspections.
You can also use `from importlib import reload` and then have an expression like reload(foo).bar() to constantly reload your foo library.
That's useful not only for breakpoints but also for errors. We can fix an error without re-running everything from zero. https://www.youtube.com/watch?v=jBBS4FeY7XM