Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
次の定義があるとしましょう。
def foo(x, y): return x + y
そして、関数のコピーが必要ですfoo( と呼びましょうbar)。ここで、xは常に に等しくなり0ます。
foo
bar
x
0
つまりbar(4)戻り4ます。
bar(4)
4
Pythonでこれを行うにはどうすればよいですか?
ありがとう!
多分このように:
bar = lambda y: foo (0, y)
ユーザーが指摘したように、fooを削除する場合は、次を使用できます。
def foo (x, y): return x + y bar = (lambda f: lambda y: f (0, y) ) (foo) print (bar (4) ) del foo print (bar (4) )