[Mailman-Users] weird problems; a cry for help
John W Baxter
jwblist at olympus.net
Sat Oct 28 07:03:13 CEST 2000
>The problem is that George's digest header had the string '% d'
>in it, and the 'string-mod' operation was trying to treat that
>as an integer format field. (the text was "10% discount").
>Erk. I think this is a Python bug; I think it should not
>treat '% d' the same as '%d'; but I'm having a hard time
>discovering anything formally specifying the format of a
>'printf-like string interpolation function of the % operator'
>in the Python documentation; any help appreciated.
I don't think it's a bug in Python but see also below.
It's a degenerate case of a "% 6d" form of specifier, in which the space
indicates that the result is space filled and the 6 gives the field width.
(a 0 indicates zero fill):
>>> "10% 6discount" % 7
>>> "10%06discount" % 18
The above comes from Python 2.0 on Mac (for convenience)...results are the
same in Python 1.5.2 on Red Hat Linux 6.2.
*Perhaps* it's a bug (or more likely mis-design) that the degenerate case
is allowed, in that there will never be fill if there isn't a width stated.
And the %% solution is the correct one (in C and in Python).
Someone with better C skills than mine (which haven't been exercised in
about 7 years) could try the samples in C (of various flavors).
John Baxter jwblist at olympus.net Port Ludlow, WA, USA
More information about the Mailman-Users