你可以用 globals() 引用全局变量。
globals()
def foo(bar=42): package_bar = globals()['bar'] do_something_with_bar(package_bar(bar))
这不应该破坏你的代码库。