Regarding h,c variables, if there’s an assignment to h anywhere in the function, Python will treat h as a local symbol that shadows h from the outer context.
Assignment to an element of h does not trigger this behavior, so the the standard workaround is to wrap the variable from outer context into a singleton list.
myvar = 5
myvar = [myvar]
def closure():
  myvar[0]=6

closure()
print(myvar[0]) # => 6