Pre-PEP: Refusing to guess in string formatting operations

Russell E. Owen no at spam.invalid
Thu Mar 13 17:47:19 EST 2003


In article <mailman.1047411920.14927.python-list at python.org>,
 Beni Cherniavsky <cben at techunix.technion.ac.il> wrote:

>(complaints about % formatted strings, including:)
>1. When you pass a single object without the singleton tuple around
>   it, your code will break it the object happens to be a tuple:
>...
>3. It is not possible to use sequences other than tuples (e.g. lists)
>   for passing multiple values to the formatting operation, because
>   the sequence is interpreted as a single object.  For example, it's
>   useful to be able to use a transparent debugging proxy that logs
>   all accesses isntead of an object; if such a proxy for a tuple is
>   used on the right side of a formatting operation, the transparency
>   breaks.  More generally, it's unpythonic to discriminate objects by
>   actual type instead of the interface they implement.

I completely agree these are problems. I personally have run into both 
of them often enough to be bugged.

I'd personally support allowing any sort of sequence and requiring a 
sequence. However, I'd be surprised if the larger community would go for 
it. Both changes are likely to break a fair amount of existing code.

-- Russell




More information about the Python-list mailing list