Use **kwargs https://stackoverflow.com/questions/1415812/why-use-kwargs-in-python-what-are-some-real-world-advantages-over-using-named:
def computeStats(func, sampleA, sampleB, **kwargs):
func(sampleA, sampleB, **kwargs)
...some actions...
return testStatistic
然后你就可以使用computeStats()
像这样:
computeStats(scipy.stats.mstats.ks_twosamp, sampleA, sampleB, alternative='greater')
也就是说,我并不完全相信您根本需要这个。简单点怎么样
def postprocessStats(testStatistic):
...some actions...
return testStatistic
postprocessStats(scipy.stats.mstats.ks_twosamp(sampleA, sampleB, alternative='greater'))
?
我认为这更容易阅读,同时也更通用。