【发布时间】:2013-03-28 17:01:15
【问题描述】:
我使用date 对象继承创建了一个类,但我无法更改应该提供给__init__ 的参数。
>>> class Foo(date):
... def __init__(self,y,m=0,d=0):
... date.__init__(self,y,m,d)
...
>>> Foo(1,1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: Required argument 'day' (pos 3) not found
我已经尝试使用super...
如果有人知道我们是否可以更改内置对象 args 或更改方法?
【问题讨论】:
标签: python class date python-2.7 python-datetime