任何语言的更友好的追溯。
项目描述
友好/友好的回溯
- friendly_traceback:帮助理解 Python 回溯
- 友好:上面的更漂亮的版本,带有一些额外的增强功能。
此代码存储库用于友好的.
除非另有说明,从这里开始,Friendly将同时指 friendly和friendly_traceback
描述
为 Python 初学者创建,但对有经验的用户也很有用, Friendly用更容易理解、可翻译成各种语言的东西代替了标准回溯。目前,Friendly提供的信息只有两种语言:英语和法语。
Friendly提供的附加信息包括
why()发生了某个异常,
what()这意味着,它究竟where()发生了,包括相关变量的值
等等。
安装
大多数用户应该安装friendly而不是friendly_traceback,
python -m pip install friendly
这需要从终端完成。在上面显示的命令中,
python指的是调用您喜欢的 Python 解释器所需的任何内容。可以是python, python3,py -3.8等。
对于一些特殊情况,包括使用像Mu这样的专用编辑器,它有自己的 Python 包安装方式,请查阅文档。
文档
例子
以下示例说明了Friendly可以提供的信息。
首先,我们展示friendly-traceback的输出
Traceback (most recent call last):
File "<friendly-console:5>", line 1, in <module>
test()
File "<friendly-console:4>", line 2, in test
a = cost(pi)
NameError: name 'cost' is not defined
Did you mean `cos`?
A `NameError` exception indicates that a variable or
function name is not known to Python.
Most often, this is because there is a spelling mistake.
However, sometimes it is because the name is used
before being defined or given a value.
In your program, `cost` is an unknown name.
Instead of writing `cost`, perhaps you meant one of the following:
* Global scope: `cos`, `cosh`, `acos`
Execution stopped on line 1 of file `'<friendly-console:5>'`.
-->1: test()
test: <function test>
Exception raised on line 2 of file `'<friendly-console:4>'`.
1: def test():
-->2: a = cost(pi)
^^^^
global pi: 3.141592653589793
接下来,使用friendly时显示为屏幕截图的相同输出。
使用友好的项目
友好/友好的回溯用于:
请随时与我联系,将您的项目添加到此列表中。
贡献
通过提出改进建议、指出文档或Friendly提供的信息中的错误或查找错误来做出贡献。
如果您说英语或法语以外的语言并感到雄心勃勃,您可能希望将翻译工作翻译成您自己的语言。
有关更多详细信息,请参阅贡献
执照:麻省理工学院
有关更多详细信息,请参阅许可证。
Sylvain Desodt从 DidYouMean-Python(又名 BetterErrorMessages)中采用了一些想法 ,该项目也使用 MIT 许可证;自 2021 年 10 月起,不再维护该特定项目。
行为守则
简而言之:尊重每个人。
有关更多详细信息,请参阅行为准则
JetBrains 支持
我们非常感谢JetBrains的支持, 这使我们能够使用 PyCharm 的专业版来开发Friendly。