Message195190
> 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__. |
|
Date |
User |
Action |
Args |
2013-08-14 18:25:41 | ethan.furman | set | recipients:
+ ethan.furman, barry, eric.smith, eli.bendersky, serhiy.storchaka |
2013-08-14 18:25:41 | ethan.furman | link | issue18738 messages |
2013-08-14 18:25:41 | ethan.furman | create | |
|