Python Inner Function Modify Outer Variable Resistor Definition