On 12/16/2011 1:36 PM, Roy Smith wrote:

What you want is an IPv6 class which represents an address in some
canonical form.  It would have constructors which accept any of the
RFC-2373 defined formats.  It would also have string formatting methods
to convert the internal form into any of these formats.

Then, instead of attempting to regex your way directly from one string
representation to another, you would do something like:

addr_string = "FEDC:BA98:7654:3210:FEDC:BA98:7654:321"
print IPv6(addr_string).to_short_form()

There are at least 2 third-party IP classes in use. I would not be surprised if at least one of them does this.

--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to