Qinao QA Wang
Qinao QA Wang

Reputation: 65

Using Output from Function 1 as Input in Function 2

so I have some code like the following:

def _step_1(a, b, c):
    some codes
    return d, e, f

def _step_2(d, e, f, a, b):
    some codes
    return g

def _run_all(a, b, c):
    g = _step_2(_step_1(a, b, c), a, b)
    return g

And it is telling me that I am missing two arguments "a" and "b". Could someone tell me if I did anything wrong by trying to save some steps? Or there is no way to save steps? I know I can definitely write like this:

def _run_all(a, b, c):
    d, e, f = _step_1(a, b, c)
    g = _step_2(d, e, f, a, b)
    return g

Upvotes: 3

Views: 58

Answers (1)

U13-Forward
U13-Forward

Reputation: 71580

If your version is python 3, use unpacking (*):

def _run_all(a, b, c):
  g = _step_2(*_step_1(a, b, c), a, b)
  return g

Upvotes: 5

Related Questions