Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (
Help us improve Python packaging - Donate today!

Python IP Calculator Module

Project Description

Project Status: Development


PyIPCalc currently fully supports CPython 2.7.

A package is availible on PyPI. Installing it is as simple as:

$ pip install pyipcalc

Source Code

Code is hosted on GitHub. Making the code easy to browse, download, fork, etc. Pull requests are always welcome!

Clone the project like this:

$ git clone

Once you have cloned the repo or downloaded a tarball from GitHub, you can install pyipcalc like this:

$ cd pyipcalc
$ pip install .

Or, if you want to edit the code, first fork the main repo, clone the fork to your desktop, and then run the following to install it using symbolic linking, so that when you change your code, the changes will be automagically available to your app without having to reinstall the package:

$ cd pyipcalc
$ pip install -e .

You can manually test changes to pyipcalc by switching to the directory of the cloned repo:

$ cd pyipcalc/tests
$ python

Using PyIPCalc

PyIPCalc 0.0.0

        Network Prefix:
        Network Address:
        First IP Address:
        Last IP Address:
        Broadcast Address:


IPV6 is supported, you can simply just provide an IPV6 prefix.

Development Module

$ python
>>> import pyipcalc
>>> net = pyipcalc.IPNetwork('')
>>> print net.prefix()
>>> print
>>> print net.first()
>>> print net.last()
>>> print net.broadcast()
>>> print net.subnet()

>>> for ip in net:
...     print ip

>>> test = pyipcalc.IPIter('',26)
>>> for net in test:
...     print net

>>> test = pyipcalc.IPIter('',26)
>>> for net in test:
...     print net.first()
...     print net.last()

Converting IPv4 to 32bit Decimal to store in database.

>>> print pyipcalc.ip2dec('',4)
>>> print pyipcalc.dec2ip(3232235520,4)

Converting IPv6 to 128bit Decimal to store in database.

>>> print pyipcalc.ip2dec('ffff:0000:0000:0000:0000:0000:0000:0000',6)
>>> print pyipcalc.dec2ip(340277174624079928635746076935438991360,6)

Typically you will need two 64bit columns in a database to store 128bit IPv6 address.

>>> print pyipcalc.dec128to64(340277174624079928635746076935438991360)
[18446462598732840960L, 0L]
>>> print pyipcalc.dec64to128(18446462598732840960L,0L)
Release History

Release History

This version
History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pyipcalc-0.0.0.tar.gz (6.9 kB) Copy SHA256 Checksum SHA256 Source Jan 17, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting