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


Groups > comp.lang.python > #73740

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <kwatch@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'argument': 0.05; '(python': 0.07; '(pos': 0.09; 'obj': 0.09; 'override': 0.09; 'subject:method': 0.09; 'def': 0.12; 'foo()': 0.16; 'typeerror:': 0.16; 'sender:addr:gmail.com': 0.17; 'subject:] ': 0.20; 'seems': 0.21; 'import': 0.22; '(such': 0.24; 'pass': 0.26; 'message- id:@mail.gmail.com': 0.30; 'file': 0.32; 'class': 0.32; '(most': 0.33; 'implemented': 0.33; 'skip:_ 10': 0.34; 'classes': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'skip:- 10': 0.38; 'recent': 0.39; 'skip:& 20': 0.39; 'subject:[': 0.39; 'to:addr:python.org': 0.39
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=s+f4dDErlKy6bfnUflmQtyIOtByJ1DY0LBoMxOF1Frg=; b=lxRmVg/ofhkDw9qir6QiETv1K7xSubYFktHo4+3wo21twF6C+/EpnMVs+UU8o69/Yg uRbqqPcWY5R8DOfKUDKaBplADaxrvVcgmnZz5kycvHRTHOff+RuHNnVh5HWl9A5YxwY+ QhM1HVmLgxM1fWhhF9aLZ2AHAODWWUo3LEbWDgsJfUiAJf0+ysj2hzQhV1F+1aPYzp4G inR6hjXCc3SSGkKbrwqEHggkPwt8ZoNBrX+imMEMSK/97D4tGhovEG5sr8yL53cRgNX6 D63thcC7hyYMPF64jpTj96ibtWzGTLaf37CV2WHncwNVCXwa6qpabGxBGQe7OyH78XAa S4ww==
MIME-Version 1.0
X-Received by 10.140.29.139 with SMTP id b11mr54233306qgb.44.1404114334639; Mon, 30 Jun 2014 00:45:34 -0700 (PDT)
Sender kwatch@gmail.com
Date Mon, 30 Jun 2014 16:45:34 +0900
X-Google-Sender-Auth pf-kbTKUp8x7O0odoA7YnJQsgZM
Subject [Q] override __init__() method of classes implemented in C
From Makoto Kuwata <kwa@kuwata-lab.com>
To python-list@python.org
Content-Type multipart/alternative; boundary=001a113a76ca23f08904fd08d8de
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11335.1404114338.18130.python-list@python.org> (permalink)
Lines 60
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1404114338 news.xs4all.nl 2859 [2001:888:2000:d::a6]:50741
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73740

Show key headers only | View raw


[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


Thread

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

csiph-web