Ethan Furman added the comment:

> 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__.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18738>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to