Suppose I have a function f that uses two helper functions h and g to get the job done. There are two possible ways of dealing with this situation.(1) take explicit arguments and returns new objects from each helper function:def f(x):    def h(x):        <do something>        return y    def g(y):        <do something else>        return z    return g(h(x))   \\ x remains unchanged(2) use the scope of f to access and mutate the original argument until it is at the desired state:def f(x):    def h():        <do something>    def g():        <do something else>    h()    g()    return x       \\ x is now differentI like situation (1) because it think it is easier to understand what is happening, but I don't really have any concrete reasons for why (1) is better other than it makes more sense to me. What is the right way to think about this?
Nested functions: should I explicitly pass arguments or rely on scope?
object oriented;functional programming;scope
Neither.  Usually in this situation, you do not want to mutate x, but you do want to take advantage of it already being in scope.  This gives you:def f(x):    def h():        <do something using x>        return y    def g(y):        <do something else>        return z    return g(h())These functions are very small typically, and using closed-over variables is to be expected and usually simplifies the interface.