本文整理汇总了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'}
示例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)
示例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()