假设我们有一个暴露函数(级别0).我们用各种参数调用这个函数.在内部,此函数调用第二个函数(级别1),但除了使用它们作为参数调用第三个函数(级别2)之外,不使用任何给定参数.然而,它可能会做一些其他的事情.
我的问题是.如何在不在中间层功能(级别1)中创建太多噪声的情况下传递参数?我列出了一些可能的方法.但请注意,其中一些是相当丑陋的,只是出于完整性的原因.我正在寻找一些既定的指导方针,而不是个人对该主题的个人意见
# Transport all of them individually down the road.
# This is the most obvious way. However the amount of parameter increases the
# noise in A_1 since they are only passed along
def A_0(msg, term_print):
A_1(msg, term_print)
def A_1(msg, term_print):
A_2(msg, term_print)
def A_2(msg, term_print):
print(msg, end=term_print)
# Create parameter object (in this case dict) and pass it down.
# Reduces the amount of parameters. However when only reading the source of B1
# it is impossible to determine what par is
def B_0(msg, term_print):
B_1({'msg': msg, 'end': term_print})
def B_1(p