Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim and python scripts debugging

Tags:

python

vim

Are there any ways to debug python scripts not leaving vim in *nix systems (executing the script, setting up breakpoints, showing variables in watch-list, etc)?

like image 604
varnie Avatar asked Dec 14 '09 13:12

varnie


People also ask

Is vim good for debugging?

Vim is a nice editor, but to do debugging I use a debugger (like GDB). But you don't have to use GDB in text mode; you can use a graphical frontend like KDbg, DDD or Insight. There are ways of getting GDB into Vim (but then you do get text based debugging). Show activity on this post.

Is Python good for debugging?

In all programming exercises, it is difficult to go far and deep without a handy debugger. The built-in debugger, pdb , in Python is a mature and capable one that can help us a lot if you know how to use it. In this tutorial, we are going to see what the pdb can do for you as well as some of its alternatives.


1 Answers

Use pdb:

import pdb def main():   list = [1,2,3]   pdb.set_trace()   list = [2,3,4]  if __name__ == '__main__':     main() 

Now run using :!python % and you'll hit your breakpoint and be able to debug interactively like in gdb.

like image 85
Pierre-Antoine LaFayette Avatar answered Oct 05 '22 15:10

Pierre-Antoine LaFayette