Search code examples
pythonclasspycharmpep8

"Ambiguous Class Definition" for classname "I" (Pep8 in Python)


Question: Why does PEP8 raise a warning PEP8: amiguous class definition 'I' when I try to define a class of name I? I could not find that there is any build-in I.

enter image description here

mwe.py:

class I:
    pass

Remarks:

  • does not occur for other one-letter names, such as class E
  • I could not access any other build-in class, object or function I
  • I didn't succeed with a web-search on this issue, as "I" is far from being a unique search term
  • observation has been made in PyCharm 2019.1.3 (Community Edition)

Solution

  • According to 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.