I\'d like to extend datetime
\'s timedelta
class with a modulo operation. I\'d also like to be able to initialize the resulting TimeDelta
c
Python doesn't go into your __init__
at all. The timedelta class defines __new__
, as you can see in the source code, and the error occurs there - which is why you don't see your code in the traceback.
(Also note that self = timedeltas[0]
doesn't do anything at all other than rebind the local name, so your code wouldn't work even if you got around the init problem.)