Python3 checks if ip address is global

I am trying to use python's “new” is_global method to determine if the IP address is allocated to public networks ( https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Address.is_global ). However, this does not work:

>>> import ipaddress
>>> ip = ipaddress.IPv4Address('192.0.2.1')
>>> ip.is_private
True
>>> ip.is_reserved
False
>>> ip.is_global
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'IPv4Address' object has no attribute 'is_global'
>>> 

As shown above, other methods like is_private work fine. I am using python 3.5.1.

Any ideas?

+4
source share
1 answer

ipaddress.py. is_global, , Spring 2014, . - .

:. @galgalesh, is_global . Python 3.5 2016-06-11.

is_global Python 3.5 +.

+3

Source: https://habr.com/ru/post/1622198/


All Articles