On 20 huhti, 18:30, [EMAIL PROTECTED] (Eddie Corns) wrote: > =?iso-8859-1?q?Pekka_J=E4rvinen?= <[EMAIL PROTECTED]> writes: > >On 20 huhti, 14:34, [EMAIL PROTECTED] (Eddie Corns) wrote: > >> Look at:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/466298 > >> it handles most of the logic of combining IP ranges. > > >> Eddie > >I'm getting error: > >Traceback (most recent call last): > > File "ipr.py", line 5, in <module> > > x = ipv4.IP4Range(ips) > > File "IP4Range.py", line 119, in __init__ > > raise TypeError("Invalid argument.") > >TypeError: Invalid argument. > > I haven't used this module for some time but if I recall your requirements > properly you need something like: > > >>> R=IP4.IP4Range() > >>> for i in ips: > > ... R=R|IP4.IP4Range(i) > ...>>> for m in R.itermasks(): > > ... print m > ... > 192.168.0.0/26 > 192.168.0.64/27 > 192.168.0.96/29 > 192.168.0.104/30 > 192.168.0.108/31 > 192.168.0.110/32 > 192.168.0.128/25 > 192.168.0.112/28 > > > > There may be an easier way my memory is hazy. > > Eddie
It does exactly what I'm after! Thanks a lot! :) -- http://mail.python.org/mailman/listinfo/python-list