def set_flags(obj, flag_field, flags):
 for flag in flags:
  if (flag[1] & flag_field):
   obj.__dict__[flag[0]] = True
  else:
   obj.__dict__[flag[0]] = False

def set_flags ( obj , flag_field , flags ) : for flag in flags : if ( flag [ 1 ] & flag_field ) : obj . __dict__ [ flag [ 0 ] ] = True else : obj . __dict__ [ flag [ 0 ] ] = False
will process the flags and set attributes in the object accordingly .