Skip to content

Instantly share code, notes, and snippets.

@Kunkgg
Created December 27, 2021 11:27
Show Gist options
  • Save Kunkgg/3ff7cf1c03817c553ade68eb9252d345 to your computer and use it in GitHub Desktop.
Save Kunkgg/3ff7cf1c03817c553ade68eb9252d345 to your computer and use it in GitHub Desktop.
python debug
  • 在源代码中设置断点
    • python 3.7 版本开始 breakpoint()
    • python 3.7 版本以前
      • import pdb; pdb.set_trace()
      • import ipdb; ipdb.set_trace()
  • 通过设置环境变量将 ipdb 设置为默认 debugger
    export PYTHONBREAKPOINT=ipdb.set_trace
    
  • IPython interactive mode alias in .pdbrc
    import IPython
    from traitlets.config import get_config
    
    cfg = get_config()
    # enable syntax highlighting
    cfg.InteractiveShellEmbed.colors = 'Linux'
    cfg.InteractiveShellEmbed.confirm_exit = False
    
    alias interacti IPython.embed(config=cfg)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment