Re: [Python-ideas] Extending __format__ method in ipaddress

2018-02-14 Thread Nick Coghlan
On 15 February 2018 at 08:29, Eric Osborne wrote: > Nick Coghlan suggested I instead extend __format__, which is what the > diffs in the current pull request do. This allows a great deal more > flexibility: the current code takes 'b', 'n', or 'x' types, as well as the > '#' option and support f

Re: [Python-ideas] Extending __format__ method in ipaddress

2018-02-14 Thread Ethan Furman
On 02/14/2018 02:29 PM, Eric Osborne wrote: Nick Coghlan suggested I instead extend __format__, which is what the diffs in the current pull request do. This allows a great deal more flexibility: the current code takes 'b', 'n', or 'x' types, as well as the '#' option and support for the '_' s

[Python-ideas] Extending __format__ method in ipaddress

2018-02-14 Thread Eric Osborne
Folks- The ipaddress library returns an IP address object which can represent itself in a number of ways: In [1]: import ipaddress In [2]: v4 = ipaddress.IPv4Address('1.2.3.4') In [3]: print(v4) 1.2.3.4 In [4]: v4 Out[4]: IPv4Address('1.2.3.4') In [6]: v4.packed Out[6]: b'\x01\x02\x03\x04'