我想继承datetime.date到一个新的对象,它需要一个额外的参数:当我尝试做的一个实例超().__ new__电话:对象没有参数
class FullDate:
def __new__(cls, lst, date): # initiate the date class - bit complicated
inst = super(FullDate, cls).__new__(cls, date.year, date.month, date.day)
# do stuff
迄今为止,我得到下面的错误:
Traceback (most recent call last):
File "<pyshell#55>", line 8, in <module>
to_load = FullDate(y[key], key)
File "/home/milo/Documents/Codes/PyFi/lib/Statement/Classes.py", line 518, in __new__
inst = super(FullDate, cls).__new__(cls, date.year, date.month, date.day)
TypeError: object() takes no parameters
我一直在研究为什么发生这种情况,但都拿出了空为止。
既然你[以前继承'datetime.date'(http://stackoverflow.com/q/28332396/3001761),你为什么要删除它? – jonrsharpe 2015-02-07 17:05:55
@jonrsharpe这让我感到最惊讶!我认为我在更新类时继承了它,然后将错误的文件推送到了git。现在感觉哑巴... – Scironic 2015-02-07 17:06:53