Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73740 > unrolled thread
| Started by | Makoto Kuwata <kwa@kuwata-lab.com> |
|---|---|
| First post | 2014-06-30 16:45 +0900 |
| Last post | 2014-06-30 16:45 +0900 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
[Q] override __init__() method of classes implemented in C Makoto Kuwata <kwa@kuwata-lab.com> - 2014-06-30 16:45 +0900
| From | Makoto Kuwata <kwa@kuwata-lab.com> |
|---|---|
| Date | 2014-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
Back to top | Article view | comp.lang.python
csiph-web