Tuesday, 27 August 2013

python - better way to pass function return to another function

python - better way to pass function return to another function

Which is the better way to pass the return value of a function as an
argument to another function in python:
val1 = function_a()
val2 = function_b(val1)
Or
val2 = function_b(function_a())
From readability perspective (and code maintenance ?) I guess the first
one is better? Is the second one better from memory perspective (one less
variable?). Which of the two is better in terms of performance?
what are the other pros and cons of these two approaches?
Also, extending it to general languages that I use, (php, c, js, perl,
java) : Is the same answer true generally for all such languages?

No comments:

Post a Comment