小编Dan*_*Dan的帖子

如何在Python中将方法作为参数传递

是否可以将方法作为参数传递给方法?

self.method2(self.method1)

def method1(self):
    return 'hello world'

def method2(self, methodToRun):
    result = methodToRun.call()
    return result
Run Code Online (Sandbox Code Playgroud)

python parameter-passing

165
推荐指数
6
解决办法
18万
查看次数

城堡中IWindsorInstaller和AbstractFacility之间的区别

我一直在使用工具来注册我的组件,但注意到了IWindsorInstaller.

它看起来与我相似,我想知道两者之间的区别是什么,应该在哪里使用.

.net castle-windsor

10
推荐指数
1
解决办法
1616
查看次数

将方法(带参数)传递给python中的另一个方法的最佳方法是什么?

将方法和方法参数传递给另一个方法的最佳方法是什么?

有没有更好的方法来做到以下几点?

def method1(name)
    return 'Hello ' + name

def method2(methodToCall, methodToCallParams, question):
    greetings = methodToCall(methodToCallParams)
    return greetings + ', ' + question

method2(method1, 'Sam', 'How are you?')
Run Code Online (Sandbox Code Playgroud)

python

2
推荐指数
1
解决办法
588
查看次数

标签 统计

python ×2

.net ×1

castle-windsor ×1

parameter-passing ×1