Created
December 1, 2012 23:47
-
-
Save BasementCat/4185986 to your computer and use it in GitHub Desktop.
Splitting an ipv6 address in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import itertools | |
address="fe80::224:8cff:fe09:98dd" | |
#verbose | |
addressLeft, addressRight=[x.split(":") for x in address.split("::")] | |
addressZeros=["0" for i in range(0, 8-(len(addressLeft)+len(addressRight)))] | |
print itertools.chain(addressLeft, addressZeros, addressRight) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment