Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73740 > unrolled thread

[Q] override __init__() method of classes implemented in C

Started byMakoto Kuwata <kwa@kuwata-lab.com>
First post2014-06-30 16:45 +0900
Last post2014-06-30 16:45 +0900
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  [Q] override __init__() method of classes implemented in C Makoto Kuwata <kwa@kuwata-lab.com> - 2014-06-30 16:45 +0900

#73740 — [Q] override __init__() method of classes implemented in C

FromMakoto Kuwata <kwa@kuwata-lab.com>
Date2014-06-30 16:45 +0900
Subject[Q] override __init__() method of classes implemented in C
Message-ID<mailman.11335.1404114338.18130.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

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 "hoge.py", line 7, in <module>
    obj = Foo()
TypeError: Required argument 'year' (pos 1) not found


It seems to be failed to override datetime.__init__() in subclass.


--
regards,
makoto kuwata

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web