擅长:python、mysql、java
<p>类可以在<code>__new__</code>或<code>__init__</code>方法中引用自身。你知道吗</p>
<pre><code>class Test(object):
def __new__(cls):
inst = object.__new__(cls)
inst.me = Test
return inst
</code></pre>
<p>或:</p>
<pre><code>class Test(object):
def __init__(self):
super(Test, self).__init__()
self.me = Test
</code></pre>
<p>或者,如果你真的想得到幻想,你可以使用<code>__metaclass__</code>。你知道吗</p>