I want to store a list of datetimes in a binary file in Python.
EDIT: by \"binary\" I mean the best digital representation for each datatype. The application for thi
By far the most simple solution is to use Temporenc: http://temporenc.readthedocs.org/
It takes care of all the encoding/decoding and allows you to write a Python datetime object to a file:
now = datetime.datetime.now()
temporenc.pack(fp, now)
To read it back, this suffices:
dt = temporenc.unpack(fp)
print(dt)