擅长:python、mysql、java
<p><code>type</code>不是函数的方式,例如:</p>
<pre><code>def foo():
pass
</code></pre>
<p>是一个函数。它像函数一样是可调用的(和Python中的许多其他对象一样),但实际上它是作为类编码的。<code>type</code>本身可以向您展示这一区别:</p>
^{pr2}$
<p>文档称它为“函数”不是因为它是如何实现的,而是因为它通常是如何使用的。这与<a href="http://docs.python.org/library/itertools.html#itertools.permutations" rel="nofollow">^{<cd3>}</a>大致相似,虽然文档没有显式地调用函数,但其隐含的含义是:</p>
<blockquote>
<p>Return successive r length permutations of elements in the iterable.</p>
</blockquote>
<p>但是<code>itertools.permutations</code>是作为一个类实现的:</p>
<pre><code>>>> type(itertools.permutations)
<class 'type'>
</code></pre>