python:debug
Python: Debug
Examine exception from interpreter | jupyter notebook 'debug' |
Pinpoint variables in scope | import IPython; IPython.embed() |
Pinpoint variables in scope | import code; code.interact(local=locals()) |
whos | |
Set breakpoint | import pudb; pudb.set_trace() |
Run with debugger | pudb – xyz.py arg1 arg2 |
Start debugger on CTRL-C | import |
pudbpudb.set_interrupt_handler() | |
Trace threads | import wdb; wdb.set_trace() |
Record logs | logging.getLogger(name) |
Debug tests | pip install pdbpp; py.test –pdb |
- Debugging Tips, Roy Hyunjin Han, PyCon Asia Pacific 2016
import sys from ptpdb import set_trace sys.breakpointhook = set_trace
# https://www.python.org/dev/peps/pep-0553/ os.environ['PYTHONBREAKPOINT'] = 'foo.bar.baz' breakpoint() # Imports foo.bar and calls foo.bar.baz() set PYTHONBREAKPOINT="from IPython import embed; embed()"
- https://github.com/Kozea/wdb # web debugger
원격 embed
print 문 대안
CPU/Memory 사용량 측정/제한
python/debug.txt · 마지막으로 수정됨: 2025/02/20 02:15 저자 rex8312