为什么 Python 不更深入地指定错误?

Why does not Python specifies errors more deeply?

我很好奇为什么 Python 不更深入地指出错误?我现在收到这个错误。

firms[i]['predmet_podnikania']=firms[i]['predmet_podnikania'][:-1]+[firms[i]['predmet_podnikania'][-1]+line]
IndexError: list index out of range

好的,我知道我正在尝试访问索引高于最大值的某个列表。但是为什么 Python 不告诉它是哪个列表?

可以是:firms[i]firms[i]['predmet_podnikania'][-1]

这会节省很多时间。

此异常在 list class 中引发。无法在 list 方法中获取变量名称 (firms),因此异常包含通用消息。