# Getting the C version of datetime: import _datetime as cdt # Getting the pure Python version of datetime: from test.support import import_fresh_module pydt = import_fresh_module("datetime", blocked=["_datetime"]) # For the following kinds of "d" dc = cdt.datetime(1, 2, 3) dp = pydt.datetime(1, 2, 3) class SubC(cdt.datetime): pass dcs = SubC(1, 2, 3) class SubPy(cdt.datetime): pass dps = SubPy(1, 2, 3) # Test the results of all the following operations for d in (dc, dp,dcs,dps): print(type(d)) try: print(d+1) except Exception as e: print(e) try: print(1+d) except Exception as e: print(e) print(d.__add__(1), d.__radd__(1), 1 .__add__(d), 1 .__radd__(d)) ## ##unsupported operand type(s) for +: 'datetime.datetime' and 'int' ##unsupported operand type(s) for +: 'int' and 'datetime.datetime' ##NotImplemented NotImplemented NotImplemented NotImplemented ## ##unsupported operand type(s) for +: 'datetime' and 'int' ##unsupported operand type(s) for +: 'int' and 'datetime' ##NotImplemented NotImplemented NotImplemented NotImplemented ## ##NotImplemented ##unsupported operand type(s) for +: 'int' and 'SubC' ##NotImplemented NotImplemented NotImplemented NotImplemented ## ##NotImplemented ##unsupported operand type(s) for +: 'int' and 'SubPy' ##NotImplemented NotImplemented NotImplemented NotImplemented