On Mon, Jun 30, 2014 at 4:52 PM, Chris Angelico wrote:
>
> Actually, __init__ isn't the problem here, __new__ is.
>
> class Foo(datetime):
> def __new__(self):
> return super().__new__(self,2014,1,1)
>
> >>> Foo()
> Foo(2014, 1, 1, 0, 0)
>
> Maybe that helps, maybe it doesn't, but the
On Mon, Jun 30, 2014 at 5:45 PM, Makoto Kuwata wrote:
> Result (Python 2.7.7 and 3.4.1):
>
> Traceback (most recent call last):
> File "hoge.py", line 7, in
>obj = Foo()
> TypeError: Required argument 'year' (pos 1) not found
>
>
> It seems to be failed to override datetime.__init__() in sub
Is it impossible to override __init__() method of classes
implemented in C (such as datetime.datetime) ?
example.py:
from datetime import datetime
class Foo(datetime):
def __init__(self):
pass
obj = Foo()
Result (Python 2.7.7 and 3.4.1):
Traceback (most recent call last):
File