Are there any ways to modify the enclosing variables with functions written outside of the main function?
I want to do this:
def modify_a():
nonlocal a
a =+ 1
def process_abc(some_criteria):
a, b, c = generate(some_criteria)
modify_a()
return a, b, c
a, b, c = process_abc()
I tried the following, but I wonder if there's a way to make the above work. If there's any, is it bad coding practice?
def modify_a(a=a):
a =+ 1
def process_abc(some_criteria):
a, b, c = generate(some_criteria)
a = modify_a(a)
return a, b, c
a, b, c = process_abc()
ais in no sense an "enclosing variable" here. You'd have to actually put the definition ofmodify_ainside the definition ofprocess_abc()for that to be true.