Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

This module allows an easy manipulation of IPV4 addresses.

Project Description

This module gives some utilities for IPV4 addresses. It defines the IP, Mask and Subnet classes. Objects of these classes should not be created directly, but rather through the function IPV4. It defines also some useful conversion functions.

>>> from IPV4 import IPV4
>>> a = IPV4('192.168.1.3')
>>> a                   # a is a string
'192.168.1.3'
>>> a.set_mask(23) # same as a = IPV4('192.168.1.3/23')
>>> a.mask         # or a = IPV4('192.168.1.3', '255.255.254.0')
'255.255.254.0'
>>> a.subnet.start
'192.168.0.0'
>>> a.subnet.end
'192.168.1.255'
>>> a.same_subnet('192.168.2.1')
False
>>> a.bitstr
'11000000101010000000000100000011'
>>> a.subnet.bitmask
'11000000101010000000000'
>>> a.hexaval
'c0a80103'
>>> a.intval
3232235779L
>>> a.IPclass
'C'
Release History

Release History

This version
History Node

0.2

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