是否有一种合理自然的方式将 python 函数转换为独立脚本?就像是:
def f():
# some long and involved computation
script = function_to_script(f) # now script is some sort of closure,
# which can be run in a separate process
# or even shipped over the network to a
# different host
不喜欢:
script = open("script.py", "wt")
script.write("#!/usr/bin/env python")
...