> This surprised me today: > > >>> import datetime > >>> datetime.datetime.today(), datetime.datetime.now() > (datetime.datetime(2015, 9, 16, 8, 44, 7, 723560), datetime.datetime(2015, > 9, 16, 8, 44, 7, 723577)) > > I naively expected today() to always return a datetime.date object. Oh > well, bug in my code has been squashed. >
Just in the case you didn't figure it out: >>> datetime.datetime.today() datetime.datetime(2015, 9, 16, 14, 50, 47, 700828) >>> datetime.date.today() datetime.date(2015, 9, 16) You were accessing the today method of the datetime property which inevitably returns a datetime object. Getting today from the date object will return an actual date. Now and today are very, very, similar - but now may be more accurate and gives flexibility with timezones as per https://docs.python.org/3/library/datetime.html#datetime.datetime.now - Nick
-- https://mail.python.org/mailman/listinfo/python-list