The Python Oracle

can't compare datetime.datetime to builtin_function_or_method

--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------

Music by Eric Matyas
https://www.soundimage.org
Track title: Hypnotic Puzzle2

--

Chapters
00:00 Can'T Compare Datetime.Datetime To Builtin_function_or_method
00:55 Accepted Answer Score 6
01:11 Thank you

--

Full question
https://stackoverflow.com/questions/3352...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #django #datetime

#avk47



ACCEPTED ANSWER

Score 6


datetime.date.today is not calling the function you think it is:

>>> import datetime
>>> datetime.date.today
<built-in method today of type object at 0x7fb681a90f80>  # NOT CALLING FUNCTION

>>> datetime.date.today()  # You need () at the end
datetime.date(2015, 11, 4) 

If you add the parentheses, you'll get the result you expect.