Global variables and functions Python
I'm trying to use a variable defined in one function in a different
function. I know I have to use Global var but I'm still not getting the
output I was expecting.
def proxycall():
global ip
global port
ip = "192.168.0.1"
port = "8080"
def web1():
class YWebPage():
def something():
var = 1
def somethingelse():
varr = 2
class Browser():
def someting():
varrr = 3
def sometingelse():
varrrr = 4
print (ip)
print (port)
web1()
This minimal version of my program is giving the traceback - NameError:
global name 'ip' is not defined.
No comments:
Post a Comment