def parse_val(v):
 if isinstance(v, (datetime.date, datetime.datetime)):
  v = unicode(v)
 elif isinstance(v, datetime.timedelta):
  v = u':'.join(unicode(v).split(u':')[:2])
 elif isinstance(v, long):
  v = int(v)
 return v

def parse_val ( v ) : if isinstance ( v , ( datetime . date , datetime . datetime ) ) : v = unicode ( v ) elif isinstance ( v , datetime . timedelta ) : v = u':' . join ( unicode ( v ) . split ( u':' ) [ : 2 ] ) elif isinstance ( v , long ) : v = int ( v ) return v
converts to simple datatypes from sql query results .