Can Not Assert Type Of An Object?
Why this source... ''' [...] ''' # Import the standard date and time system. from datetime import datetime as dt # Ommited the remaining imports section class CuteClass(object)
Solution 1:
Rather than comparing to type
(which you certainly shouldn't do as a string!), use isinstance
. Also, you shouldn't use assert
like that, try something like:
ifnotisinstance(date, dt): # note you have aliased datetime.datetimeraise TypeError(...)
Post a Comment for "Can Not Assert Type Of An Object?"