Reputation: 2098
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
Upvotes: 1
Views: 95
Reputation: 798556
Because Python is strongly typed, and neither u'0'
nor '0'
are equal to 0
.
Upvotes: 1