Professional Python Debugging
Effective debugging saves hours of development time.
Using pdb
import pdb
def buggy_function(x):
pdb.set_trace() # Breakpoint
result = x / 0
return result
Logging Instead of Print
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
logger.debug("Debug message")
logger.info("Info message")
logger.error("Error message")
{# Provenance for articles generated from a source document. Rendered
here rather than stored in the body so it stays accurate and cannot
be edited away, and so the sealed draft stays purely generated. #}
Discussion 0
No comments yet. Be the first to start the discussion!
Leave a Comment