R
Rob Conner
So this is simple, why can't I run the following code? I've tried many
variances of this, but simply cannot inherit from datetime or
datetime.datetime. I get this on line 3.
TypeError: function takes at most 2 arguments (3 given)
********************************
import datetime
_datetime = datetime.datetime
class MyDateTime(_datetime):
"""
Identical to builtin datetime.datetime, except it accepts
invalid dates and times as input.
"""
_valid = True
def __init__(self, year, month, day, *args, **kw):
try:
_datetime.__init__(self, year, month, day, *args, **kw)
except _datetime.ValueError:
_valid = False
self.year = year
self.month = month
self.day = day
self.args = args
self.kw = kw
********************************
variances of this, but simply cannot inherit from datetime or
datetime.datetime. I get this on line 3.
TypeError: function takes at most 2 arguments (3 given)
********************************
import datetime
_datetime = datetime.datetime
class MyDateTime(_datetime):
"""
Identical to builtin datetime.datetime, except it accepts
invalid dates and times as input.
"""
_valid = True
def __init__(self, year, month, day, *args, **kw):
try:
_datetime.__init__(self, year, month, day, *args, **kw)
except _datetime.ValueError:
_valid = False
self.year = year
self.month = month
self.day = day
self.args = args
self.kw = kw
********************************