problem with eval and time
rosuav at gmail.com
Tue Nov 6 05:38:47 CET 2012
On Tue, Nov 6, 2012 at 3:29 PM, Wincent <ronggui.huang at gmail.com> wrote:
> I fetch data from social networking sites and want to mark the time of access. I store all the information in a redis database, which converts everything into strings and I need to convert those strings back to original python objects when analyzing the data.
The easiest way, imho, is to store Unix times - simply the number of
seconds since 1970, as an integer or float. That can easily and safely
be turned into a string and back (floats might lose a little accuracy,
depending on how you do it, but the difference will be a small
fraction of a second).
time.struct_time(tm_year=2012, tm_mon=11, tm_mday=6, tm_hour=4,
tm_min=35, tm_sec=47, tm_wday=1, tm_yday=311, tm_isdst=0)
Easy and unambiguous. Also compact, which may or may not be a selling point.
More information about the Python-list