This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients barry, eli.bendersky, eric.smith, ethan.furman, serhiy.storchaka
Date 2013-08-14.17:50:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1376502624.83.0.0440092301745.issue18738@psf.upfronthosting.co.za>
In-reply-to
Content
I think:

>>> '{:}'.format(AF.IPv4)
'AF.IPv4'

is correct, assuming str(AF.IPv4) is 'AF.IPv4'. I'm not sure what:

>>> '{:10}'.format(AF.IPv4)

should produce. There's a special case for an empty format string calling str().

I think that specifying __format__() would be best, except then you need to decide what sort of format specification language you want to support, and deal with all of the implementation details. Or, maybe just have Enum's __format__ be:

    def __format__(self, fmt):
        return format(str(self), fmt)

which makes the format specification language match str's.

%-formatting is a whole different thing, of course.
History
Date User Action Args
2013-08-14 17:50:24eric.smithsetrecipients: + eric.smith, barry, eli.bendersky, ethan.furman, serhiy.storchaka
2013-08-14 17:50:24eric.smithsetmessageid: <1376502624.83.0.0440092301745.issue18738@psf.upfronthosting.co.za>
2013-08-14 17:50:24eric.smithlinkissue18738 messages
2013-08-14 17:50:24eric.smithcreate