“cmd.identify” returns a list of atom IDs corresponding to the ID code of atoms in the selection.
list = cmd.identify(string selection="(all)",int mode=0)
def identify(selection="(all)",mode=0,quiet=1):
identify | api