I am trying to compile the old code of 2008 .
import datetime if isinstance(value, datetime.date):
But I have an error:
isinstance () arg 2 must be a class, type or tuple of classes and types Python executable: /usr/bin/python2.6 Python Version: 2.6.5
What am I missing?
I suspect that you imported the wrong date-time, as in:
from datetime import datetime
use instead:
import datetime
I run Python 2.7 and sometimes also came across this error. Often a simple type check will suffice unless you need a strict instance check.
if id(type) and type(value) in (datetime.datetime, datetime.date): #somecode