if not [True]*3 == [isinstance(i, int) for i in [days, months, years]]:
raise TypeError('days, months, and years must be int type not %s %s %s'
% (type(days), type(months), type(years)))
Basically want to check if days, months, and years is an int, the most compact way I could thing of is above but I'm not sure it's the best but I believe it would be better than multiple if statements for each int.
if not all(isinstance(i, int) for i in [days, months, years])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.