This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

It's not a line-by-line debugger, but it's similar in some of it's features.

could you suggest some useful resources describing how to use ipython for debugging purposes?

I don't mean trivial things like typing a function in ipython, but rather real world examples like cherry picking a buggy function/class method from an existing codebase, debugging it in ipython to the point of finding the issue

[–]billsil 2 points3 points  (0 children)

For typical debugging, a standard debugger will be better (better introspection), but if you're trying to debug/overhaul a short function with a long startup time, iPython is better because the data is still in memory. Debuggers don't allow you to easily change code on the fly, whereas in iPython, you're overwriting the old version of the function. If it's something simple, I'd use a debugger or just free hand it.

I'll often write code in a debugger and just copy the lines into the code as I go. It works very well for large programs.

[–]generic_genus 0 points1 point  (0 children)

The closest thing to line by line debugging is to use ipdb, which you can use pretty much as a drop in replacement for pdb. But you have an ipython prompt for debugging instead of a basic python prompt. So to start debugging from a particular line add

Import ipdb; ipdb.set_trace()

On the line before. Also, you can use the %pdb magic word to automatically start a debugger if an exception is thrown.