set a setting

def set(self, value):
        '''set a setting'''
        if value == 'None' and self.default is None:
            value = None
        if value is not None:
            if self.type == bool:
                if str(value).lower() in ['1', 'true', 'yes']:
                    value = True
                elif str(value).lower() in ['0', 'false', 'no']:
                    value = False
                else:
                    return False
            else:
                try:
                    value = self.type(value)
                except:
                    return False
        if self.range is not None:
            (minv,maxv) = self.range
            if value < minv or value > maxv:
                return False
        if self.choice is not None:
            found = False
            for v in self.choice:
                if v.lower() == value.lower():
                    found = True
                    value = v
                    break
            if not found:
                print("Must be one of %s" % str(self.choice))
                return False
        self.value = value
        return True