PyCon 2016 in Portland, Or
hills next to breadcrumb illustration

Monday 10:50 a.m.–11:20 a.m.

Machete-mode debugging: Hacking your way out of a tight spot

Ned Batchelder

Audience level:
Intermediate
Category:
Best Practices & Patterns

Description

When chasing mysterious bugs, it's helpful to use all the tools at your disposal. We'll explore ways to use Python's dynamic tools to help track down the cause of head-scratching problems in large systems. Tools include the inspect module, monkey-patching, trace functions, and the Python mechanisms at work behind them all.

Abstract

Python provides a malleable and introspectable runtime environment. Good discipline requires restraint from using too many of those dynamic tools, but sometimes they are invaluable. When chasing mysterious bugs, it's helpful to use all the tools at your disposal. In this talk, we'll investigate some ways to use Python's dynamic nature to help track down the cause of head-scratching problems in large systems. We'll touch on the inspect module, monkey-patching, and trace functions, among others. Along the way, we'll talk about many fundamental Python mechanisms: the ones that cause the problems, the one that diagnose them, and the ones that solve them. Good engineering principles go out the window in our pursuit of the information we need!