擅长:python、mysql、java
<p>Python数据模型的文档建议使用<code>__new__</code>:</p>
<p><a href="http://docs.python.org/reference/datamodel.html#object.__new__" rel="noreferrer">object.<strong>new</strong>(cls[, ...])</a></p>
^{bq}$
<p>对于你所举的例子,应该这样做:</p>
<pre><code>class C(int):
def __new__(cls, val, **kwargs):
inst = super(C, cls).__new__(cls, val)
inst.a = kwargs.get('a', 0)
return inst
</code></pre>