python函数传多个参数_python – 如何通过几个函数传递多个参数

假设我们有一个暴露函数(级别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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值