Generating and printing a range of ip addresses
Stephen Briley
sdb1031 at yahoo.com
Sat Feb 14 02:36:12 EST 2004
Hi all,
I would like to write a python script that takes input
of 2 ip address, one a start address and the other the
end address and prints a list of all ip address in
between in dotted-decimal format. I've attempted to
use the ipv4 module
(http://pynms.sourceforge.net/ipv4.html) ,but I am
unable to get past this error "AttributeError: 'str'
object has no attribute '_address".
Can any suggest a solution to this problem? Is there a
better way than using the ipv4 module?
Thanks,
Steve
>>> from ipv4 import *
>>> ip = IPv4('10.0.0.1')
>>> startadd = ip.nexthost()
>>> endadd = ('10.0.3.0')
>>> print startadd
10.0.0.2
>>> print endadd
10.0.3.0
>>> while startadd != endadd:
... startadd = ip.nexthost()
... print startadd
...
Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python23\lib\ipv4.py", line 250, in __cmp__
return cmp(self._address, other._address)
AttributeError: 'str' object has no attribute '_address'
__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html
More information about the Python-list
mailing list