Skip to content

Instantly share code, notes, and snippets.

View purple4reina's full-sized avatar
💜

Rey Abolofia purple4reina

💜
View GitHub Profile
@ChrisTM
ChrisTM / ip.py
Last active April 20, 2022 09:35
Convert IPv4 addresses to and from integers
"""
Convert between various representations of an IPv4 address.
`ip` refers to a dotted string, like: `'127.0.0.1'`.
`octets` are indexables, like `(127, 0, 0, 1)`.
`int` is the integer representation, like `2130706433`.
Written for Python 2.7.
"""