Python: Testing for unicode, and converting to time()
Question: Sometimes self.start is unicode:

eg.

    
    
    >>>self.start
    u'07:30:00'
    

Which makes datetime.combine complain

    
    
    start = datetime.combine(self.job_record.date, self.start)
    

How does one:

  1. Test for unicode?
  2. Convert from u'07:30:00' to datetime.time?


Answer: Checking for unicode:

    
    
    >>> import types
    >>> type(u'07:30:00') is types.UnicodeType
    True
    >>> type('regular string') is types.UnicodeType
    False
    

Converting strings to time:

    
    
    >>> import time
    >>> time.strptime(u'07:30:00', '%H:%M:%S')
    (1900, 1, 1, 7, 30, 0, 0, 1, -1)
    

