Get yun ip address with python

Hi gays,

I’m trying to get the ip address of my yun with python. It looks very simple but does not work.

import socket
sock = socket.gethostbyname(socket.gethostname())
Traceback (most recent call last):
File “”, line 1, in
socket.gaierror: [Errno -2] Name or service not known

Any suggestions?
Thanks Andreas

s.connect(('', 0))

'' is router's address.