import maya.cmds
import maya.OpenMaya
targetNode = maya.cmds.createNode('transform')
maya.cmds.addAttr(targetNode, ln='input', m=True, v=True)
for index in [12, 13, 16, 23]:
maya.cmds.setAttr('{0}.input[{1}]'.format(targetNode, index), index)
selList = maya.OpenMaya.MSelectionList()
maya.OpenMaya.MGlobal.getSelectionListByName(targetNode, selList)
depNode = maya.OpenMaya.MObject()
selList.getDependNode(0, depNode)
depUtils = maya.OpenMaya.MFnDependencyNode(depNode)
inputPlug = depUtils.findPlug('input')
print inputPlug.name()
indices = maya.OpenMaya.MIntArray()
inputPlug.getExistingArrayAttributeIndices(indices)
print indices
print inputPlug.numElements()
indexToRead = 0
print inputPlug.elementByPhysicalIndex(indexToRead).name()
#-----------------------------------------------------------------------------------------------------------------------
"""
elementByPhysicalIndex(indexToRead) == indices[indexToRead]
what is dangerous if you use elementByLogicalIndex is that maya will create an input/output element at this connection index if its empty(its the standard behavior by the way).
in your datablock it migh be better to avoid using MPlug ( you can do everything cleanly with attribute).