【问题标题】:Implementing custom debugger function using breakpoint()使用 breakpoint() 实现自定义调试器功能
【发布时间】:2022-01-04 19:05:54
【问题描述】:

我正在尝试实现一个自定义调试器功能,它只会在我正在创建的包中满足特定条件时插入断点:

def custom_debug():
    if(condition):
       return breakpoint()
    esle:
       pass

但是,当我在另一个文件中导入我的包时:

from my_package import module as m

def test():
    print("First")
    m.custom_debug()
    print("Second")

这会跳过函数并打印两行。我怎样才能让它使用我的自定义函数插入断点?

【问题讨论】:

    标签: python debugging remote-debugging vscode-debugger


    【解决方案1】:

    我认为您忘记将您的条件传递给 custom_debug。 试试这个:

    def custom_debug(condition):
        if condition:
           return breakpoint()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-01-11
      • 1970-01-01
      • 2015-12-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多