import socket
import sys
import urllib
port = 6669
mac = "e448c7a96170"
try:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
ip = socket.gethostbyname( mac + '.rtn.iptv.svt.sciatl.com')
sock.connect((ip, port))
print(ip)
sock.send("getdom;ipg")
print "Message Sent"
while True:
global m;
m=sock.recv(10000)
print(m)
sock.close()
except:
print sys.exc_info()
Hi folks I am new to the python.I am trying to print the 'm' value.But it is not printing it since the print statement is outside the loop. I am trying to store the received data in a global variable and use it in the later part.But I am not able to do as the 'm' variable is not visible outside.Any help is appreciated. Thank you
global mdoesn't makes any sense here.globalis for functions.