[issue32820] Add __format__ method to ipaddress

2019-09-12 Thread Zachary Ware
Zachary Ware added the comment: New changeset f9c95a4ba24c52eb1c052e3052d677e90a429a9a by Zachary Ware (ewosborne) in branch 'master': bpo-32820: __format__ method for ipaddress (#5627) https://github.com/python/cpython/commit/f9c95a4ba24c52eb1c052e3052d677e90a429a9a -- nosy: +zach.

[issue32820] Add __format__ method to ipaddress

2018-03-04 Thread Eric Osborne
Eric Osborne 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 falling through to regular form

[issue32820] Add __format__ method to ipaddress

2018-02-23 Thread Nick Coghlan
Nick Coghlan added the comment: I think supporting "s" makes sense, as we're going to need to treat the empty format string as implying "s" for backwards compatibility reasons: >>> f"{v4}" '1.2.3.4' Right now, attempting to format that field without `!s` will give you a TypeError, bu

[issue32820] Add __format__ method to ipaddress

2018-02-23 Thread Eric Osborne
Eric Osborne 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.2.3.4' In [21]: int(a) Out[21

[issue32820] Add __format__ method to ipaddress

2018-02-23 Thread Eric V. Smith
Eric V. Smith added the comment: True enough. You'd think that I (of all people!) would know that. Nevermind. -- ___ Python tracker ___

[issue32820] Add __format__ method to ipaddress

2018-02-23 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: You always can use f'{addr!s:20}'. -- ___ Python tracker ___ ___ Python-bugs-list mailing list U

[issue32820] Add __format__ method to ipaddress

2018-02-23 Thread Eric V. Smith
Eric V. Smith added the comment: I'd like 's' to be supported, and just be passed to format(str(self), fmt) (or some alternate spelling for the same thing). My use case is to format tables including addresses: print(f'{addr:20s} {hostname}') -- __

[issue32820] Add __format__ method to ipaddress

2018-02-20 Thread Nick Coghlan
Nick Coghlan added the comment: I've updated the issue title to reflect the revised proposal (i.e. using __format__ rather than a new IP address specific method). -- title: Add bits method to ipaddress -> Add __format__ method to ipaddress ___ Pytho