Debugging Python Like a Boss
zapier.com
Debugging Python Like a Boss
1–10 of 100 posts
Re: Debugging Python Like a Boss
#2Re: Debugging Python Like a Boss
#3 import pdb; pdb.set_trace();
There's a chance you forget this, check-in, and it ends in production. Use pdb facilities instead: $ python -m pdb
Then set a breakpoint and continue: (Pdb) break :
(Pdb) c
This is trivial to automate from any editor or command line, so you don't even have to guess the path to the file.EDIT: For the lazy, here's a script to set breakpoints from the command line and run your scripts:
Re: Debugging Python Like a Boss
#4Re: Debugging Python Like a Boss
#5Looks really good.
Re: Debugging Python Like a Boss
#6I've always find it interesting how the Python/Ruby community debug your code both during development (coding or writing unit-tests) and perhaps in production as well (for the record, I use "print" as my debugging tool).
I'm a long time Eclipse user who has recently converted to IntelliJ (almost a year) and the debugger that comes with these editors is something I can't live without hence I have not moved to Emacs or VI(m) or whatever the UNIX hackers use because it would crippled my productivity significantly (or so I thought, feel free to criticize my point of view).
So sometimes I'm wondering how productive Python/Ruby + VIM/Emacs users. Just an honest question really.
PS: most Java IDE debuggers can do local AND remote AND has some support for hotswap code.
Re: Debugging Python Like a Boss
#7A good list of libraries, but please, don't use this in the middle of your code to set a break point: import pdb; pdb.set_trace(); There's a chance you forget this, check-in, and it ends in production. Use pdb facilities instead: $ python -m pdb Then set a breakpoint and continue: (Pdb) break : (Pdb) c This is trivial to automate from any editor or command line, so you don't even have to guess the path to the file. E…
Re: Debugging Python Like a Boss
#8I've been using Python for a while for fun and Ruby (Rails) on and off. I've always find it interesting how the Python/Ruby community debug your code both during development (coding or writing unit-tests) and perhaps in production as well (for the record, I use "print" as my debugging tool). I'm a long time Eclipse user who has recently converted to IntelliJ (almost a year) and the debugger that comes with these edit…
Re: Debugging Python Like a Boss
#9A good list of libraries, but please, don't use this in the middle of your code to set a break point: import pdb; pdb.set_trace(); There's a chance you forget this, check-in, and it ends in production. Use pdb facilities instead: $ python -m pdb Then set a breakpoint and continue: (Pdb) break : (Pdb) c This is trivial to automate from any editor or command line, so you don't even have to guess the path to the file. E…
Re: Debugging Python Like a Boss
#10very nice! plug: if you happen to be on windows, try PTVS which has nice features like mixed-mode Python/C++ debugging as well cross debugging from Visual Studio linux & MacOS. (it's a free plug-in). http://www.youtube.com/watch?v=wvJaKQ94lBY