[issue32820] Add bits method to ipaddress

Eric Osborne report at bugs.python.org
Sun Feb 11 12:26:06 EST 2018


Eric Osborne <eric at notcom.com> added the comment:

redoing with a bits() property method to return a string, a la:

    def bits(self):
        fstr = '0' + str(IPV4LENGTH) + 'b'
        return '0b' + format(int(self), fstr)


Works thusly:

import ipaddress as ip
a = ip.IPv4Address('0.0.0.42')
a.bits == '0b00000000000000000000000000101010'

----------
resolution: rejected -> 
title: Add binary methods to ipaddress -> Add bits method to ipaddress

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32820>
_______________________________________


More information about the Python-bugs-list mailing list