Pre-PEP: Refusing to guess in string formatting operations

John Roth johnroth at ameritech.net
Tue Mar 11 16:15:32 EST 2003


"Beni Cherniavsky" <cben at techunix.technion.ac.il> wrote in message
news:mailman.1047411920.14927.python-list at python.org...
> Here is something I cooked a week ago but managed to post only now
> because it was buried in a damaged disk :-).  Please comment on it.
>
> Also availiable on
>
> http://www.technion.ac.il/~cben/python/pep-strfmt.txt
> http://www.technion.ac.il/~cben/python/pep-strfmt.html
>
> --
> Beni Cherniavsky <cben at tx.technion.ac.il>,
> happy that cdrecord works in his linux - one less reason to reboot...

Your first proposal won't make the issue go away. I'm simply
not that rigorous that I remember each and every time to wrap
the right operand to '%' with a tuple.

Frankly, if there's going to be a fix, the one I'd rather see is a
recognition that the programmer knew what he was doing, and
if the '%' processor sees a tuple when there is only one request
in the pattern string, then format it as a tuple if that's possible
given
the format code.

As far as the second proposal is concerned,
I'd prefer a built-in rather than a string method, but either would
do nicely. Either one has the additional benefit that it fixes
the line continuation problem with print and the format operation
rather cleanly.

First proposal: -1
Second proposal: + 1/2

John Roth








More information about the Python-list mailing list