def to_python(self,value):
if value==self.emptyValue or value in EMPTY_VALUES:<EOL><INDENT>return self.emptyValue<EOL><DEDENT>try:<EOL><INDENT>value=self.coerce(value)<EOL><DEDENT>except(ValueError,TypeError,ValidationError):<EOL><INDENT>raise ValidationError(self.error_messages['<STR_LIT>']%{'<STR_LIT:value>':value})<EOL><DEDENT>return value<EOL>
Validates that the value is in self.choices and can be coerced to the right type.