擅长:python、mysql、java
<p>您可以设置单个(function/lambda/etc…)对象的属性:</p>
<pre><code>l = lambda x: x*2
def fun():
return 1
l.f = fun
l.f()
1
</code></pre>
<p>您不能对<em>所有</em>函数执行此操作-必须手动将其添加到每个函数中。你知道吗</p>
<p>您可以编写一个短包装,然后<code>mylambda(lambda x: ...)</code>:</p>
<pre><code>def mylambda(x):
x.f = fun
return x
</code></pre>