当前位置: 首页>>代码示例>>Python>>正文


Python Pdb.set_trace方法代码示例

本文整理汇总了Python中IPython.core.debugger.Pdb.set_trace方法的典型用法代码示例。如果您正苦于以下问题:Python Pdb.set_trace方法的具体用法?Python Pdb.set_trace怎么用?Python Pdb.set_trace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPython.core.debugger.Pdb的用法示例。


在下文中一共展示了Pdb.set_trace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: IPdbKernel

# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import set_trace [as 别名]
class IPdbKernel(Kernel):
    implementation = 'IPdbKernel'
    implementation_version = '0.1'
    language = 'IPdb'
    language_version = '0.1'
    language_info = {'mimetype': 'text/plain'}
    banner = "IPython debugger kernel"

    def __init__(self, **kwargs):
        Kernel.__init__(self, **kwargs)

        # Instantiate IPython.core.debugger.Pdb here, pass it a phony 
        # stdout that provides a dummy flush() method and a write() method
        # that internally sends data using a function so that it can
        # be initialized to use self.send_response()
        write_func = lambda s: self.send_response(self.iopub_socket,
                                                  'stream',
                                                  {'name': 'stdout',
                                                   'text': s})
        sys.excepthook = functools.partial(BdbQuit_excepthook,
                                           excepthook=sys.excepthook)
        self.debugger = Pdb(stdout=PhonyStdout(write_func))
        self.debugger.set_trace(sys._getframe().f_back)

    def do_execute(self, code, silent, store_history=True,
                   user_expressions=None, allow_stdin=False):
        if not code.strip():
            return {'status': 'ok', 'execution_count': self.execution_count,
                    'payload': [], 'user_expressions': {}}

        # Process command:
        line = self.debugger.precmd(code)
        stop = self.debugger.onecmd(line)
        stop = self.debugger.postcmd(stop, line)
        if stop:
            self.debugger.postloop()

        return {'status': 'ok', 'execution_count': self.execution_count,
                'payload': [], 'user_expression': {}}

    def do_complete(self, code, cursor_pos):
        code = code[:cursor_pos]

        default = {'matches': [], 'cursor_start': 0,
                   'cursor_end': cursor_pos, 'metadata': dict(),
                   'status': 'ok'}

        if not code or code[-1] == ' ':
            return default

        # Run Pdb.completenames on code, extend matches with results:
        matches = self.debugger.completenames(code)

        if not matches:
            return default

        return {'matches': sorted(matches), 'cursor_start': cursor_pos-len(code),
                'cursor_end': cursor_pos, 'metadata': dict(),
                'status': 'ok'}
开发者ID:lebedov,项目名称:ipdbkernel,代码行数:61,代码来源:ipdbkernel.py

示例2: trace

# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import set_trace [as 别名]
def trace():
    """like pdb.set_trace() except sets a breakpoint for the next line
    
    works with nose testing framework (uses sys.__stdout__ for output)
    """
    frame = sys._getframe().f_back
    pdb = Pdb(color_scheme='Linux', stdout=sys.__stdout__)
    pdb.set_trace(frame)
开发者ID:jagguli,项目名称:PyBug,代码行数:10,代码来源:bug.py

示例3: main

# 需要导入模块: from IPython.core.debugger import Pdb [as 别名]
# 或者: from IPython.core.debugger.Pdb import set_trace [as 别名]
def main():
  """ This is the main entry point for training and testing your classifier. """
  classifier = Classifier()
  experiment = Experiment(classifier)
  experiment.train('training')
  
  # Sanity check. Should get 100% on the training images. 
  report = experiment.test('training')
  report.print_summary()
  
  Pdb.set_trace()

  test_datasets = 'translations rotations scales noise occlusion distortion blurry_checkers'
  final_report = ClassificationReport("All Datasets")
  
  # Print the classification results of each test
  for dataset in test_datasets.split():
    report = experiment.test('testing/' + dataset)
    report.print_summary()
    #report.print_errors() # Uncomment this to print the error images for debugging. 
    final_report.extend(report)
  
  final_report.print_summary()
开发者ID:mrastegari,项目名称:Basic_Image_Classification,代码行数:25,代码来源:main.py


注:本文中的IPython.core.debugger.Pdb.set_trace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。