Python Forum

Full Version: module ipaddress
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
today, i was reading through the doc for module ipaddress. i have already used this module, but i am going through everything again, more slowly this time because i missed a lot the first time. so as i was reading i expected to see a function to convert IPv6Address types to a full format, fd00:1::5 -> fd00:0001:0000:0000:0000:0000:0000:0005. but i saw no such function. it would not be hard to write one, but i just never tried because i figured there already was one. so, did i miss this on an even slower read, or will i not be abused for writing one?
There is exploded in ipaddress module.

>>> import ipaddress
>>> ip_6 = ipaddress.ip_address('fd00:1::5')
>>> ip_6.exploded
'fd00:0001:0000:0000:0000:0000:0000:0005' 
There is Python HOWTO-s >>> An introduction to the ipaddress module which "aims to provide a gentle introduction to the ipaddress module". There are lot of examples (including exploded) etc. It may be worth to have look at it.
ah... that's how i missed it. it has a bad name. it should be "expanded" or "full". i need to read even slower so my brain doesn't just look for things, but looks at everything there.