Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73740
| Date | 2014-06-30 16:45 +0900 |
|---|---|
| Subject | [Q] override __init__() method of classes implemented in C |
| From | Makoto Kuwata <kwa@kuwata-lab.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.11335.1404114338.18130.python-list@python.org> (permalink) |
[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 comp.lang.python | Previous | Next | Find similar | Unroll thread
[Q] override __init__() method of classes implemented in C Makoto Kuwata <kwa@kuwata-lab.com> - 2014-06-30 16:45 +0900
csiph-web