I am getting an error message that says
AttributeError: 'NoneType' object has no attribute 'something'
How can I understand this message?
What general scenarios might cause such an AttributeError
, and how can I identify the problem?
This is a special case of AttributeError
s. It merits separate treatment because there are a lot of ways to get an unexpected None
value from the code, so it's typically a different problem; for other AttributeError
s, the problem might just as easily be the attribute name.
See also What is a None value? and What is a 'NoneType' object? for an understanding of None
and its type, NoneType
.
AttributeError
, to include in the see-also section. stackoverflow.com/questions/11685936 is not suitable, because it was caused by a typo (mixed tab/space indentation) that has 2.x-specific effects, which causes confusion and inaccuracy in the answers. – Wrung