the Gravity of Python 2

Chris Angelico rosuav at gmail.com
Wed Jan 8 23:34:17 EST 2014


On Thu, Jan 9, 2014 at 3:29 PM, Roy Smith <roy at panix.com> wrote:
> So, I'd like to see your code which generates an aware UTC datetime
> object in Python.  And then we can argue about whether it's simple or
> not :-)

Like I said, I don't use the datetime module. But fundamentally, an
aware datetime represents an instant in time - which is exactly what a
POSIX timestamp ("time_t") represents. So I can't offer exact code for
working with them, other than to say that time.time() is precisely
accomplishing the same job. Maybe there needs to be a recipe posted
somewhere saying "To create a datetime from a POSIX time, do this".

This is simple:

>>> time.time()
1389242048.669482

ChrisA



More information about the Python-list mailing list