[issue32820] Add bits method to ipaddress

2018-02-12 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: IPv6 is nasty no matter how you do it (cf. https://tools.ietf.org/html/rfc1924). And the ipaddr library already has hex (packed()). Binary's not about direct readabilty, but about ease of comparison. It's much easier to show the

[issue32820] Add binary methods to ipaddress

2018-02-11 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: test_not_an_index_issue15559() disallows __index__, so nevermind. Will resubmit without __index__ to get the full binary string, though. -- resolution: -> rejected ___ Python tra

[issue32820] Add binary methods to ipaddress

2018-02-11 Thread Eric Osborne
New submission from Eric Osborne <e...@notcom.com>: This issue adds two things to the ipaddress lib: * an __index__ method to allow bin(), oct(), hex() to work * a property method to get the fully padded (32-bit or 128-bit) address as a string -- components: Library (Lib) me

[issue32820] Add bits method to ipaddress

2018-02-11 Thread Eric Osborne
Eric Osborne <e...@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.

[issue32820] Add bits method to ipaddress

2018-02-11 Thread Eric Osborne
Change by Eric Osborne <e...@notcom.com>: -- keywords: +patch pull_requests: +5434 stage: -> patch review ___ Python tracker <rep...@bugs.python.org> <https://bugs.pyt

[issue32820] Add bits method to ipaddress

2018-02-11 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: Faster, too. My way: In [7]: %timeit bits(a) 1.67 µs ± 7.31 ns per loop (mean ± std. dev. of 7 runs, 100 loops each) Your way: In [11]: %timeit b2(a) 1.2 µs ± 5.93 ns per loop (mean ± std. dev. of 7 runs, 100 loops each) I was a

[issue32820] Add bits method to ipaddress

2018-02-13 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: This is an interesting idea. I hacked together something to handle IPv4 and pushed it to the repository. It works, but I'm afraid it may be kinda ugly. Do you have any examples of good, pythonic ways to parse the format string or oth

[issue32820] Add bits method to ipaddress

2018-02-14 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: Cool, I will kick it over to python-ideas. I checked in some code to handle the format string and it's a lot like what you're suggesting, so I'll leave that in there and see what happens. Thanks! eric On Tue, Feb 13, 2018 at 11:56 P

[issue32820] Add bits method to ipaddress

2018-02-20 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: Yeah, bits() is dead. The thread has the same title, but I changed the PR a while ago. The diffs in the PR are for format(). I'll go over the code and clean it up. The docstring in particular is probably lousy. Thanks! eric On Tue,

[issue32820] Add __format__ method to ipaddress

2018-02-23 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: I dunno, I think this might be useful. A binary representation is itself a string, and takes formatting as such (ditto for hex, as hex(int()) returns a string: In [20]: a Out[20]: IPv4Address('1.2.3.4') In [92]: f'{a}' Out[92]: '1

[issue32820] Add bits method to ipaddress

2018-02-19 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: I brought it up on python-ideas. Since I've not been through this process before - what happens now? Do I wait for code review on github, or is there more I need to do? eric On Tue, Feb 13, 2018 at 11:56 PM Nick Coghla

[issue32820] Add __format__ method to ipaddress

2018-03-04 Thread Eric Osborne
Eric Osborne <e...@notcom.com> added the comment: I have pushed out new diffs. * moved __format__ to _BaseAddress, where it should have been in the first place * redid format parser as regexp, as it was getting awfully complicated * added support for 'X' * added support for 's' by f

[issue32820] Add and document __format__ method for IPv[46]Address

2020-10-17 Thread Eric Osborne
Eric Osborne added the comment: Yes, I agree. Regardless of backport policy, this is a handy little convenience featurette, not sliced bread v2, so it's not worth backporting even if it was permissible. eric On Fri, Oct 16, 2020 at 7:13 PM Eric V. Smith wrote: > > Eric V. Smith

[issue32820] Add and document __format__ method for IPv[46]Address

2020-10-17 Thread Eric Osborne
Eric Osborne added the comment: Did I really ship an enhancement without documenting it? I am a terrible person. I will pick up the issue and take care of it. eric On Sat, Oct 17, 2020 at 9:07 AM Eric V. Smith wrote: > > Eric V. Smith added the comment: > > I've created

[issue43039] tempfile.TemporaryDirectory() name string is incorrect

2021-01-27 Thread Eric Osborne
New submission from Eric Osborne : When I create a temporary directory, the name doesn't come back in a way the application expects it. I ran into this using gitPython and I'm not entirely clear whether it's a tmpfile issue or a gitpython issue, but I think it's tempfile. Repro: In [12

[issue32820] Add bits method to ipaddress

2018-02-12 Thread Eric Osborne via Python-bugs-list
Eric Osborne <e...@notcom.com> added the comment: It is often useful to have non-decimal representations of IP addresses. Hex shows up a lot in sniffer traces, which is why I wanted to provide __index__, but that's not going to happen. I use binary a lot when teaching subnet masking and a