'Given a value, infer the correct data type'

def data_type_for_value(self, value):

    if (value is None):
        data_type = self.TYPE_NULL
    elif ((value is True) or (value is False)):
        data_type = self.TYPE_BOOL
    elif isinstance(value, (int, float)):
        data_type = self.TYPE_NUMERIC
    elif (not value):
        data_type = self.TYPE_STRING
    elif isinstance(value, (datetime.datetime, datetime.date)):
        data_type = self.TYPE_NUMERIC
    elif (isinstance(value, basestring) and (value[0] == '=')):
        data_type = self.TYPE_FORMULA
    elif self.RE_PATTERNS['numeric'].match(value):
        data_type = self.TYPE_NUMERIC
    elif (value.strip() in self.ERROR_CODES):
        data_type = self.TYPE_ERROR
    else:
        data_type = self.TYPE_STRING
    return data_type
