You should (almost) always normalise whitespace in any text string that is intended for insertion in a database (or for many other purposes).
To normalise whitespace is to (1) strip any leading whitespace (2) strip any trailing whitespace (3) replace any internal runs (length >= 1) of whitespace by exactly 1 SPACE (U+0020).
Whitespace should not be limited to what standard Python provides, especially if you are working in Python 2.X and not using unicode objects. For example, in the default "C" locale, "\xA0" is not treated as whitespace but it's very likely to represent NO-BREAK SPACE (U+00A0).
Sample code for Python 2.X:
def normalize_white_space_u(unicode_object):
return u' '.join(unicode_object.split())
def normalize_white_space_s(str_object):
return ' '.join(str_object.replace('\xA0', ' ').split())
Generalizing the second function: replace each occurrence of a non-standard whitespace character by a single space and then do the split-join dance.