README 810 B

1234567891011121314151617181920212223242526
  1. ipaddress
  2. =========
  3. Python 3.3+'s [ipaddress](http://docs.python.org/dev/library/ipaddress) for Python 2.6, 2.7, 3.2.
  4. Note that as in Python 3.3+ you must use character strings and not byte strings for textual IP address representations:
  5. ```python
  6. >>> from __future__ import unicode_literals
  7. >>> ipaddress.ip_address('1.2.3.4')
  8. IPv4Address(u'1.2.3.4')
  9. ```
  10. or
  11. ```python
  12. >>> ipaddress.ip_address(u'1.2.3.4')
  13. IPv4Address(u'1.2.3.4')
  14. ```
  15. but not:
  16. ```python
  17. >>> ipaddress.ip_address(b'1.2.3.4')
  18. Traceback (most recent call last):
  19. File "<stdin>", line 1, in <module>
  20. File "ipaddress.py", line 163, in ip_address
  21. ' a unicode object?' % address)
  22. 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?
  23. ```