如何知道异常点

时间:2016-06-06 14:11:42

标签: python pdb

我有一个500Mb的源代码,有超过5K的用Python编写的文件。有时我会收到异常消息,但不知道异常的行号和文件名。即使有时在终端未点亮时也看不到异常,我特意使用pdb。

有没有方便的方法来了解异常位置?

感谢。

1 个答案:

答案 0 :(得分:1)

Try the traceback module: https://docs.python.org/3/library/traceback.html

It contains the tb_lineno function which takes the traceback as a parameter, returning the line number of the exception.

EDIT:

var LayoutView = Marionette.LayoutView.extend({
  template: false,
  el: '.container',
  regions: {
    'regionWithCollectionView': '.collection-view-container'
  },
  childEvents: {
    'channel:selected':'channelSelected'
  },
  channelSelected: function (childView, args) {
    console.log("layoutview::channelSelected - child " + childView.model.get('channel') + " selected");
  }
});