Discuss / Python / 每个函数一层一层调用都这么传参数那还得了?

每个函数一层一层调用都这么传参数那还得了?

Topic source

def process_student(name): std = Student(name)

# std是局部变量,但是每个函数都要用它,因此必须传进去:
do_task_1(std)
do_task_2(std)

def do_task_1(std): do_subtask_1(std) do_subtask_2(std)

def do_task_2(std): do_subtask_2(std) do_subtask_2(std)

到底是怎么得了了,为什么不能一直这样传参数,求解释


  • 1

Reply