How to import a function with a variable and make that variable global

16 Views Asked by At

config.py

import telnetlib

def my_function(a):
    tn=telnetlib.Telnet(a)

main.py

import config.py

HOST=172.25.25.5
config.my_function(HOST)

tn.write(b"show run".encode('ascii') + b"\n")

This code will return 'tn' is not defined. How do I gain access to the variable 'tn' after importing from config.py to main.py?

0

There are 0 best solutions below