couple of ways,
if the object is named ball then use "ball" in whatever it is you're trying to do
for ex:
mc.getAttr("ball.translateX")
another way is
mc.select("ball")
selection = mc.ls(sl=True)
mc.getAttr(selection + ".translateX")
assuming maya.cmds have been imported as mc