擅长:python、mysql、java
<p>您应该能够使用<code>types.FunctionType</code>来执行您想要的操作:</p>
<pre>
Python 2.6.1 (r261:67515, Jul 7 2009, 23:51:51)
[GCC 4.2.1 (Apple Inc. build 5646)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import types
>>> help(types.FunctionType)
Help on class function in module __builtin__:
class function(object)
| function(code, globals[, name[, argdefs[, closure]]])
|
| Create a function object from a code object and a dictionary.
| The optional name string overrides the name from the code object.
| The optional argdefs tuple specifies the default argument values.
| The optional closure tuple supplies the bindings for free variables.
</pre>
<p>但是通常,<code>def</code>被认为是<code>function</code>类型的默认构造函数。在</p>