[issue44655] Confusing error with __slots__

Eric V. Smith report at bugs.python.org
Fri Jul 16 15:21:56 EDT 2021


Eric V. Smith <eric at trueblade.com> added the comment:

Also, the dot after the first 'b' was confusing to me: I thought it had something to do with an attribute of b. And the quotes around the second 'b' were also confusing, but that's mostly because the original example initialized a class variable named 'b' with the str value 'b'.

Maybe a better error would use a colon:

AttributeError: foo: Did you mean: 'foo1'?

Looking at 3.10s behavior, I can't decide what logic it's using to suggest something:

>>> 'foo'.formatx
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'formatx'. Did you mean: 'format'?
>>> class C: pass
...
>>> C().a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'C' object has no attribute 'a'

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44655>
_______________________________________


More information about the Python-bugs-list mailing list