Python 3.3+'s ipaddress for older Python versions (LADI project)
Go to file
Philipp Hagemeister d8aef06cc3 release 1.0.23 2019-10-18 03:30:15 +02:00
.dockerignore Add a dockerfile to test building on Python2.6 2019-10-18 02:37:59 +02:00
.gitignore ignore MANIFEST file 2016-09-09 18:55:47 +02:00
.travis.yml travis: add final newline 2019-10-18 03:19:17 +02:00
LICENSE Add LICENSE file (#13) 2014-09-14 12:15:37 +02:00
MANIFEST.in PyPi release: include license 2015-12-28 18:09:07 +01:00
Makefile travis: Run flake8 only on Python 2.7 2019-10-18 03:16:39 +02:00
OTHER_BACKPORTS.md Correct capitalization of PyPI 2018-09-16 11:48:54 -07:00
README Create a symlink to README for distutils/sdist 2015-07-14 21:34:17 +02:00
README.md README: Clarify that we are backporting 3.8+, not 3.3 2019-10-18 03:26:17 +02:00
ipaddress.py release 1.0.23 2019-10-18 03:30:15 +02:00
setup.cfg Distribute package as a universal wheel 2018-04-10 20:12:00 -07:00
setup.py release 1.0.23 2019-10-18 03:30:15 +02:00
test-python2.6.Dockerfile Comprehensive docker testing 2019-10-18 03:05:06 +02:00
test-python2.7.Dockerfile Comprehensive docker testing 2019-10-18 03:05:06 +02:00
test-python3.2.Dockerfile Comprehensive docker testing 2019-10-18 03:05:06 +02:00
test-python3.3.Dockerfile Comprehensive docker testing 2019-10-18 03:05:06 +02:00
test_ipaddress.py lint 2019-10-18 02:50:14 +02:00

README.md

ipaddress

Python 3.3+'s ipaddress for Python 2.6, 2.7, 3.2.

This repository tracks the latest version from cpython, e.g. ipaddress from cpython 3.8 as of writing.

Note that just like in Python 3.3+ you must use character strings and not byte strings for textual IP address representations:

>>> from __future__ import unicode_literals
>>> ipaddress.ip_address('1.2.3.4')
IPv4Address(u'1.2.3.4')

or

>>> ipaddress.ip_address(u'1.2.3.4')
IPv4Address(u'1.2.3.4')

but not:

>>> ipaddress.ip_address(b'1.2.3.4')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "ipaddress.py", line 163, in ip_address
    ' a unicode object?' % address)
ipaddress.AddressValueError: '1.2.3.4' does not appear to be an IPv4 or IPv6 address. Did you pass in a bytes (str in Python 2) instead of a unicode object?