Skip to main content
 首页 » 编程设计

python之flake8: E743 函数定义不明确 'O'

2025年05月04日12落叶

当我在一个只有一行的文件上运行 flake8 时:def O(): pass 我得到了以下错误,尽管函数运行得很好:

/tmp/a.py:1:5: E743 ambiguous function definition 'O' 

为什么 flake8 失败了?为什么我不只是收到警告?

请您参考如下方法:

来自documentation :

Do not define functions named 'l', 'o', or 'i' (E743)
Functions named I, O, and l can be very hard to read. This is because the letter I and the letter l are easily confused, and the letter O and the number 0 can be easily confused.

Change the names of these functions to something more descriptive.

Additional links
- https://www.python.org/dev/peps/pep-0008/#names-to-avoid