On Wed, Aug 19, 2009 at 2:44 PM, Nick Coghlan<ncogh...@gmail.com> wrote: > 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.
ah, I see. I'll make this fix and I think this might actually simplify the code. just to double check, it's fine for IPNetwork to remain hashable if set_prefix() actually returned a new object, correct? > Cheers, > Nick. > > -- > Nick Coghlan | ncogh...@gmail.com | Brisbane, Australia > --------------------------------------------------------------- > _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com