Without the rename, "python -m doctest" isn't smart enough to figure
out that this thing is a python file.
}
-def convert_ip(ip):
- """Convert a hex string representing an IP address to conventional
+def convert_ip(ip : str):
+ """
+ Convert a hex string representing an IP address to conventional
human-readable form, ie. dotted-quad decimal for IPv4, and
8 colon-separated hex shorts for IPv6.
+
+ Examples
+ --------
+
+ >>> convert_ip("7f000001")
+ '127.0.0.1'
+ >>> convert_ip("00000000000000000000ffff7f000001")
+ '0000:0000:0000:0000:0000:ffff:7f00:0001'
+
"""
if len(ip) == 8:
# IPv4, eg. "7f000001" -> "127.0.0.1"