def _get_my_ip():
 csock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
 csock.connect(('8.8.8.8', 80))
 (addr, _port) = csock.getsockname()
 csock.close()
 return addr

def _get_my_ip ( ) : csock = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM ) csock . connect ( ( '8.8.8.8' , 80 ) ) ( addr , _port ) = csock . getsockname ( ) csock . close ( ) return addr
returns the actual ip of the local machine .