Generating and printing a range of ip addresses

RayS rays at blue-cove.com
Sat Feb 14 11:04:55 EST 2004


At 11:36 PM 2/13/04 -0800, Stephen Briley wrote:
>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".

The prob is your're comparing ip.nexthost() and '10.0.3.0', i.e, a object 
and an  string.

>Can any suggest a solution to this problem?

Try:
while str(startadd) != endadd:
...

Ray 





More information about the Python-list mailing list