I’m having problems with python variable scopes.
def getIP(data,address):
header = Header.fromData(data,0);
arcount = header._arcount //at this point arcount is some non-zero number
later in the code (still inside the method getIP) I want to see if arcount is zero or not:
...
elif firstRR._type==RR.TYPE_NS:
while(nscount!=0):
print "arcount: ",arcount //here it gives 0. why?
if(arcount!=0):
print "arcount isn't 0"
else:
print "can't reach header"
And this prints “can’t reach header”, when I was assuming arcount shouldn’t be zero. Why it doesn’t see arcount? Thanks
Because Python is strongly typed, and neither
u'0'nor'0'are equal to0.