Re: datetime.datetime.today()

2015-09-16 Thread Michiel Overtoom
This bit me once. I was comparing a date to a datetime, both representing the same day, so I expected them to be the same, but I was wrong. What I should have done was extracting the date of the datetime with the .date() function, and only then compare it to the other date: >>> import datetime

Re: datetime.datetime.today()

2015-09-16 Thread Skip Montanaro
On Wed, Sep 16, 2015 at 8:55 AM, Nick Sarbicki wrote: > 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) > Yeah, I was aware of that. That is partly why I th

Re: datetime.datetime.today()

2015-09-16 Thread Nick Sarbicki
> 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