Is there an easy way of calculating number of IPs from 2 given IP addresses?
Question: I want to calculate number of number of IP addresses from 2 given IP
addresses.

Example: 127.0.1.10 and 127.0.0.200 is 67 IP addresses..

What's easy way of doing this?

I've seen other examples, but I'm looking for a Python example. Thanks.


Answer: 
    >>> import socket
    >>> def iptoint(ip):
    ...     return int(socket.inet_aton(ip).encode('hex'), 16)
    ... 
    >>> iptoint('127.0.0.200')
    2130706632
    >>> iptoint('127.0.1.10') - iptoint('127.0.0.200')
    66
    >>> def ipdistance(ip1, ip2):
    ...     return abs(iptoint(ip1) - iptoint(ip2)) + 1
    ... 
    >>> ipdistance('127.0.1.10', '127.0.0.200')
    67
    

