inner_net = False p_ip = '1.1.1.1' t_ip = '2.2.2.2' def switch_ip(a, b, c): if a: b = c return b return b def read_apps(): # global p_ip p_ip = switch_ip(inner_net, p_ip, t_ip) print(p_ip) if __name__ == '__main__': read_apps()