g.d.d.c. is right, but adding a very frequent example:
You might call this function in a recursive form. In that case, you might end up at null pointer or NoneType
. In that case, you can get this error. So before accessing an attribute of that parameter check if it's not NoneType
.