I’ve been looking for the NoneType for half a day. I’ve put ‘print’ and dir() all through the generation of the Object represented by t2. I’ve looked at the data structure after the crash using ‘post mortem’ and nowhere can I find a NoneType.
I was wondering if perhaps it’s one of those errors that are initiated by some other part of the code (wishful thinking) and I was wondering if anybody recognizes this?
( k2 is an ‘int’ )
File "C:\Python26\Code\OO.py", line 48, in removeSubtreeFromTree
assert getattr(parent, branch) is subtreenode
TypeError: getattr(): attribute name must be string, not 'NoneType
File "C:\Python26\Code\OO.py", line 94, in theSwapper
st2, p2, b2 = self.removeSubtreeFromTree(t2, k2)
TypeError: 'NoneType' object is not iterable
NoneTypeis the type of theNoneobject. So, in the first error,branchisNone. The second error is tougher to diagnose without seeing the source code, but suggests that somewhere int2, the data structure isn’t exactly as you believe.When this comes up for me, I usually find that I’ve forgotten to end one of my functions with a
returnstatement. Functions without an explicit return will returnNone.