[Python-3000] More PEP 3101 changes incoming

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Aug 3 04:03:52 CEST 2007


Guido van Rossum wrote:
> In order to support the use cases for %s and %r, I propose to allow
> appending a single letter 's', 'r' or 'f' to the width_specifier
> (*not* the conversion_specifier):
> 
>  'r' always calls repr() on the object;
>  's' always calls str() on the object;
>  'f' calls the object's __format__() method passing it the
> conversion_specifier, or if it has no __format__() method, calls
> repr() on it. This is also the default.

Won't it seem a bit unintuitive that 'r' and 's' have
to come before the colon, whereas all the others come
after it?

It would seem more logical to me if 'r' and 's' were
treated as special cases of the conversion specifier
that are recognised before calling __format__.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiem!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-3000 mailing list