from bge.logic import getCurrentController
...
myXObjects = getObjectsByPrefix("X_")
...
def getObjectsByPrefix(prefix):
scene = getCurrentController().owner.scene
return [gameObject for gameObject in scene.objects
if gameObject.name.startswith(prefix)]