python - "Ambiguous Class Definition"类名 "I"(Python 中的 Pep8)

标签 python class pycharm pep8

问题: 为什么当我尝试定义名称为 I 的类时,PEP8 会发出警告 PEP8: amiguous class definition 'I'?我找不到任何内置的 I

enter image description here

mwe.py:

class I:
    pass

备注:

  • 不会出现在其他单字母名称中,例如 class E
  • 我无法访问任何其他内置类、对象或函数 I
  • 关于这个问题我没有成功进行网络搜索,因为“”远不是一个独特的搜索词
  • 观察已在PyCharm 2019.1.3(社区版)

最佳答案

根据 PEP 8: Names to avoid :

Never use the characters 'l' (lowercase letter el), 'O' (uppercase letter oh), or 'I' (uppercase letter eye) as single character variable names.

In some fonts, these characters are indistinguishable from the numerals one and zero. When tempted to use 'l', use 'L' instead.

关于python - "Ambiguous Class Definition"类名 "I"(Python 中的 Pep8),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56617521/

相关文章:

python - User 类应该是不可变的吗?

java - 如何打印类变量 - java

python mysqldb更新变量在列表中的位置

python - 从 shell 脚本调用 python 函数

python - 如何用 "--no-binary"编写 requirements.txt 文件?

ios - View Controller 和类之间有什么区别

pycharm - 如何在嵌入式本地终端中前进后退一个字

python - 如何让 PyQt4 与 PyCharm 一起工作

django - 使用 pycharm 调试器调试在 docker 镜像中运行的 django 应用程序

javascript - jinja2.exceptions.TemplateSyntaxError : expected token ',' , 得到 'static'