“cmd.flag” sets the indicated flag for atoms in the selection and clears the indicated flag for atoms not in the selection.
cmd.flag(int flag, string selection, string action="reset", int indicate=0)
def flag(flag, selection, action="reset", quiet=1):