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 ethan.furman
Recipients barry, eli.bendersky, eric.smith, ethan.furman, serhiy.storchaka
Date 2013-08-14.18:25:41
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <520BCBA5.8010706@stoneleaf.us>
In-reply-to <1376502624.83.0.0440092301745.issue18738@psf.upfronthosting.co.za>
Content
> Eric V. Smith added the comment:
>
> 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.

I disagree.  A subclass shouldn't have to write code to provide the /same/ behavior as its superclass, just code for 
different behavior.  In the cases of
     '%d' % int_subclass
or
     '{:d}'.format(int_subclass)

str should be smart enough to actually produce the numeric value, not rely on the subclass' __repr__.
History
Date User Action Args
2013-08-14 18:25:41ethan.furmansetrecipients: + ethan.furman, barry, eric.smith, eli.bendersky, serhiy.storchaka
2013-08-14 18:25:41ethan.furmanlinkissue18738 messages
2013-08-14 18:25:41ethan.furmancreate