I'm not sure if it's what you told me to do but I did it like this :
def isEdgesConnected(e1Index=None, e2Index=None, objShape=None):
if not objShape:
# Get the object from selection
sel = om.MSelectionList()
om.MGlobal.getActiveSelectionList(sel)
else:
sel = om.MSelectionList()
cmds.select('{0}.e[{1}]'.format(objShape, e1Index), '{0}.e[{1}]'.format(objShape, e2Index), r=True)
om.MGlobal.getActiveSelectionList(sel)
component = om.MObject()
meshDagPath = om.MDagPath()
sel.getDagPath(0, meshDagPath, component)
eIter = om.MItMeshEdge(meshDagPath, component)
eIter2 = om.MItMeshEdge(meshDagPath, component)
while not eIter.isDone():
eIter2.next()
returnValue = eIter.connectedToEdge(eIter2.index())
break
return returnValue
Now I can call the function like this :
isEdgesConnected(281, 282, 'pSphereShape1')
isEdgesConnected()
What I mean by more direct way is to note hqve to select anything like a did in my script (cmds.select('{0}.e[{1}]'.format(objShape, e1Index), '{0}.e[{1}]'.format(objShape, e2Index), r=True)) and just give this information directly in a function.