简单的问题:如何将任意 args 列表传递给 python 可调用对象?
假设我想从命令行调用一个函数,如下所示:
my_script.py foo hello world
使用以下脚本:
import myfuncs
f = getattr(myfuncs, sys.args[1])
if f and callable(f):
# This is the bit I don't know. I effectively want f(sys.args[2:])
我确信有办法做到这一点,但我必须忽略它。