def set(self, val):
    if (val in self.extra):
        self.set_bits(self.extra.index(val))
    elif isinstance(val, int):
        self.set_bits(val)
    else:
        raise TypeError('Invalid value {val} for {cls}'.format(val=val, cls=self.__class__.__name__))
def set(self, val):
    if (val in self.extra):
        self.set_bits(self.extra.index(val))
    elif isinstance(val, int):
        self.set_bits(val)
    else:
        raise TypeError('Invalid value {val} for {cls}'.format(val=val, cls=self.__class__.__name__))