I like this script because it will deliver the pi external ip address without asking a website like info.io to get it
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try: s.connect(('10.255.255.255', 1)); IP = s.getsockname() # doesn't even have to be reachable
except: IP = 'unknown'
Unfortunately it only works for 3G dongles not wifi dongles working through a router. Networking confuses me. Why is it usual to ask someone else for your own external ip address? Why can't the network fess up itself?