How should I check that a given argument is a datetime.date object?
- by rmh
I'm currently using an assert statement with isinstance. Because datetime is a subclass of date, I also need to check that it isn't an instance of datetime. Surely there's a better way?
from datetime import date, datetime
def some_func(arg):
assert isinstance(arg, date) and not isinstance(arg, datetime),\
'arg must be a datetime.date object'
# ...