Quick example

 
import maya.OpenMaya as OpenMaya

m_obj       = OpenMaya.MObject() # should get from any code above
m_dagPath   = OpenMaya.MDagPath()
if m_obj.hasFn( OpenMaya.MFn.kDagNode ):
    OpenMaya.MDagPath.getAPathTo( m_obj, m_dagPath )
    print( m_dagPath.fullPathName() )