code: def set_flagstate(flagset):
      
      if not flagset <= _all_flags:
          raise ValueError("unrecognized flags in flagset")
  
      for f in flagset:
          set_flag(f)
      for f in _all_flags - flagset:
          clear_flag(f)
docs: Set all flags in ``flagset``, and clear all other flags.