The Python Equivalent of byebug is pdb.set_trace()
source link: https://fuzzyblog.io/blog/python/2019/09/24/the-python-equivalent-of-byebug-is-pdb-set-trace.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
The Python Equivalent of byebug is pdb.set_trace()
Sep 24, 2019
In ruby the debugger is invoked by adding the statement
byebug
wherever you want to debug your code. This is preceded, of course, by a reference in Gemfile that brings in the byebug gem.
The python equivalent of this is two fold:
- import the pdb (python debugger) gem
- add the line pdb.set_trace() call where you want it
Here's the color coded example:
import pdb
# lines of python code here
pdb.set_trace()
That will launch the python debugger right before the line where the pdb.set_trace() call is inserted. Here are some useful commands:
- The s key steps thru the code.
- The n key goes to the next line.
- The q key quits.
More on Python Debugging.
Posted In: #python #debugging
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK