Skip to main content

Democritus IP Addresses

PyPI CI Lint codecov The Democritus Project uses semver version 2.0.0 The Democritus Project uses ruff to format and lint code License: LGPL v3

Democritus functions[1] for working with IP addresses.

[1] Democritus functions are simple, effective, modular, well-tested, and well-documented Python functions.

We use d8s (pronounced "dee-eights") as an abbreviation for democritus (you can read more about this here).

Installation

pip install d8s-ip-addresses

Usage

You import the library like:

from d8s_ip_addresses import *

Once imported, you can use any of the functions listed below.

Functions

  • def ipv4_address_examples(n: int = 10):
        """Create n ipv4 addresses."""
    
  • def ipv6_address_examples(n: int = 10):
        """Create n ipv6 addresses."""
    
  • def ipv4_addresses_find(text):
        """Parse IPv4 addresses from the given text."""
    
  • def ipv6_addresses_find(text):
        """Parse IPv6 addresses from the given text."""
    
  • def ip_addresses_find(text):
        """Parse ip addresses from the given text."""
    
  • def ip_is_private(ip):
        """Check if the IP address is private."""
    
  • def is_ip_address(text):
        """Determine whether or not the given text is an ip address."""
    
  • def ip_whois(ip):
        """Get whois information for the given ip address."""
    
  • def ip_is_reserved(ip):
        """Check if the IP address is IETF (https://www.ietf.org/) reserved."""
    
  • def ip_version(ip):
        """Get the version number of the ip address (4 or 6)."""
    
  • def ip_network_block_first_address(network_block: str):
        """Return the first address of the given network_block."""
    
  • def ip_network_block_last_address(network_block: str):
        """Return the first address of the given network_block."""
    
  • def ip_network_block_ip_count(network_block_string):
        """Get the number of IP addresses in the given network block."""
    
  • def ip_network_block_to_range(network_block_string):
        """Return the range of IP addresses covered by the network block in the form "<starting-ip> - <ending-ip>"."""
    
  • def ip_network_block_enumerate(network_block_string):
        """Return a list of all of the ip addresses in the given network_block_string."""
    
  • def ip_network_block_contains_ip(network_block: str, ip_address: str):
        """."""
    
  • def ip_in_network_block(ip_address: str, network_block: str):
        """Return whether or not the given ip_address is in the network_block."""
    
  • def ip_range_to_network_block(ip_range_string):
        """Take a range like "<starting-ip> - <ending-ip>" and convert this into an IP address network block."""
    
  • def ipv6_expand(ip_v6):
        """Expand (also known as 'Exploding') an ipv6 address."""
    
  • def ipv6_compress(ip_v6):
        """Compress an ipv6 address."""
    
  • def ipv6_threatconnect_form(ip_v6):
        """Format ipv6 address as expected by ThreatConnect."""
    
  • def ip_current():
        """Get the current ip address."""
    
  • def ipv4_private_addresses():
        """Get private ipv4 addresses from https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml."""
    
  • def ipv6_private_addresses():
        """Get private ipv6 addresses from https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml#iana-ipv6-special-registry-1."""
    
  • def ipv4_sum(ipv4_address):
        """Find the sum of the ip address by adding each section of the ip address. For example, 8.8.8.8 would sum to 32 (calculated by taking 8 + 8 + 8 + 8)"""
    
  • def ipv4_is_possible_version_number(ipv4_address):
        """Determine whether or not the ipv4 ip address is likely a version number or not. This is a beta function and is a work in progress. The word "Possible" in the function name should be taken seriously; this function will return `True` if the ipv4_address *might* be a version number. The results of this function are conjecture and should not be used definitively."""
    

Development

👋  If you want to get involved in this project, we have some short, helpful guides below:

If you have any questions or there is anything we did not cover, please raise an issue and we'll be happy to help.

Credits

This package was created with Cookiecutter and Floyd Hightower's Python project template.

Release files for d8s-ip-addresses 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for d8s-ip-addresses 0.7.0
File Size Uploaded
d8s_ip_addresses-0.7.0.tar.gz 96.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for d8s-ip-addresses 0.7.0
File Interpreter ABI Platform
d8s_ip_addresses-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 117.0 kB

Release files / d8s_ip_addresses-0.7.0.tar.gz

Download URL d8s_ip_addresses-0.7.0.tar.gz
Size 96.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f8e8e415ce8d5490b971c7ebd6f5d8030e20d1cfcd90fa5d8e5012cb9e9dfa20
BLAKE2b-256 checksum
How to use checksums
0138e03292d984cdac0e202e413732938f0881a47ed0b8a1078a13f6f16d05b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release files / d8s_ip_addresses-0.7.0-py3-none-any.whl

Download URL d8s_ip_addresses-0.7.0-py3-none-any.whl
Size 21.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f118682671ae8d2929fc736d611db0df98a80f429e94a0f7d6e589761727dda8
BLAKE2b-256 checksum
How to use checksums
b216654c4634fbed03cd3f0945fe7914eeb0fc43c24080aaad46dcf0cd38c4f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 1, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page