A lot of Python debugging frustration can be avoided by activating the ‘Show White Space and TAB’ option from the View > Show Symbol menu.
This view option displays yellow dots for White Spaces and yellow arrows for TAB indents in the script, and can save precious time locating places where the indentation is wrong.
How to get an object transformation matrix relative to another object’s coordinates:
* The following script requires selecting 2 objects, the function will return the transform matrix of the first object relative to the transform matrix of the second.