Python Nested Function Access Outer Variable Resistor