A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-August/091264.html below:

[Python-Dev] PEP 3144: IP Address Manipulation Library for the Python Standard Library

[Python-Dev] PEP 3144: IP Address Manipulation Library for the Python Standard LibraryNick Coghlan ncoghlan at gmail.com
Wed Aug 19 23:44:17 CEST 2009
Peter Moody wrote:
> you can't set them directly, if that's what you mean.
> 
>>>> import ipaddr
>>>> o = ipaddr.IPv4Network('1.1.1.0/24')
>>>> o.broadcast
> IPv4Address('1.1.1.255')
>>>> o.network
> IPv4Address('1.1.1.0')
>>>> o.broadcast = ipaddr.IPv4Address('1.1.1.127')
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> AttributeError: can't set attribute
>>>> o.prefixlen = 25
>>>> o.broadcast
> IPv4Address('1.1.1.127')

IPAddress instances should definitely be hashable, but as long as
"prefixlen" is mutable, IPNetwork instances should *not* be hashable,
since their value can change.

If prefixlen was made read only, then IPNetwork instances could also be
made hashable. In that case, changing the prefix length would then have
to be done by creating a new instance.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4