NoneType attribute error in Python?
Recently while running a Python program I encountered an error AttributeError: 'NoneType' object has no attribute 'xxx'
.
When looking at the code, I could not initially identify why this was happening. Later on I realized that I was setting an attribute on a function that was returning ‘None’ .
Therefore whenever you encounter this error always make sure that you are not trying to access or set an attribute on a None
value.
Below Screenshot has example of such scenario :-
