Conocer la IP asociada a un interfaz de red (solo para Linux)

Transcribo una receta, de código Python, publicada en ActiveState Code por Paul Cannon, donde se ve como conocer la dirección IP asociada a un interfaz de red (bajo Linux) mediante la llamada a sistema ioctl SIOCGIFADDR.

1
2
3
4
5
6
7
8
9
10
11
import socket
import fcntl
import struct
 
def get_ip_address(ifname):
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
return socket.inet_ntoa(fcntl.ioctl(
[...]

Publishing objects from Zope’s products

Creating Zope homemade products is the best way to developing Python web applications without depending (if you don’t want) from Plone. Until last wednesday, I had tried some methods to manage Python’s objects directly from ZPT pages but didn’t work. Other problem with Zope is the documentation and the community, there are too few documentation, [...]