On 8/2/07, Greg Ewing <[EMAIL PROTECTED]> wrote: > 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?
That depends on how you think of it. My point is that these determine which formatting API is used. > 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__. But that would make it impossible to write a __format__ method that takes a string that *might* consist of just 'r' or 's'. The conversion specifier should be completely opaque (as it is in .NET). -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
