In Python, how do I convert a datetime.datetime into the kind of float that I would get from the time.time function?
Given a datetime.datetime object dt, you could use
(dt - datetime.datetime.utcfromtimestamp(0)).total_seconds()
Example:
>>> dt = datetime.datetime.now(); t = time.time()
>>> t
1320516581.727343
>>> (dt - datetime.datetime.utcfromtimestamp(0)).total_seconds()
1320516581.727296
Note that the timedelta.total_seconds() method was introduced in Python 2.7.