def validate(self, value):
        "Check that value has same type and passes validator."
        if not isinstance(value, type(self.value)):
            raise TypeError('Value has a different type!')
        if not self.__validator(value):
            raise ValueError('Validator failed the value!')
Check that value has same type and passes validator.
recipes/Python/578195_Setting_Namespaces/recipe-578195.py