Reputation: 51
I'm trying to use python's "new" is_global method to determine, wether an ip address is allocated for 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, the other methods like is_private work fine. I'm using python 3.5.1.
Any insights?
Upvotes: 4
Views: 2950
Reputation: 559
I had a look at a bug report here and went to check the ipaddress.py
module. While there exists an is_global
attribute it is clearly not implemented and the bug report remains open and unresolved from Spring 2014 so I wouldn't hold my breath. If necessary you could get in touch with someone from the original bug report and get a status update.
UPDATE: According to user @galgalesh, at the time of writing this question, the is_global
attribute was not implemented. That bug was resolved in Python 3.5 on 2016-06-11.
Attribute is_global
is implemented as of Python 3.5+.
Upvotes: 3