try:
basestring = basestring
except NameError:
basestring = str
from itertools import ifilter
except ImportError:
ifilter = filter