Skip to content

Instantly share code, notes, and snippets.

@BasementCat
Created December 1, 2012 23:47
Show Gist options
  • Save BasementCat/4185986 to your computer and use it in GitHub Desktop.
Save BasementCat/4185986 to your computer and use it in GitHub Desktop.
Splitting an ipv6 address in python
#!/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