[Python-Dev] FW: PEP 292, Simpler String Substitutions

Damien Morton damien.morton@acm.org
Thu, 20 Jun 2002 13:45:03 -0400


Youre right. I only threw that out there as a talking point rather than
a serious suggestion.

I take it you agree with my assertion that putting the format string
before the variable would be less error prone? (if it didn=92t destroy =
the
current usage).

Given that the $ notation is all-new, perhaps prefixing with the format
string should be considered

as in:

"$4.2f{height}"

In fact, if we are going to revisit format strings why not ditch the
format character and keep the numeric specifier only. Determine the
format character by the type of the variable.

For x =3D "hello", "$4.2{x}" =3D=3D "$4s{x}" -> "hell"
For x =3D 3.7865, "$4.2{x}" =3D=3D "$4.2f{x}" -> "3.78"


> -----Original Message-----
> From: pinard@titan.progiciels-bpi.ca
> [mailto:pinard@titan.progiciels-bpi.ca] On Behalf Of Fran=E7ois Pinard
> Sent: Thursday, 20 June 2002 10:39
> To: Damien Morton
> Subject: Re: PEP 292, Simpler String Substitutions
>=20
>=20
> [Damien Morton]
>=20
> > Why not alter the notation to allow the format specifier to come
> > before the name part.  "%4.2f(height)" I think would be a whole lot=20
> > less error prone, and would allow for the format specifier=20
> to default
> > to "s" where omitted.
>=20
> Hello, Damien.
>=20
> "%4.2f(height)" already has the meaning of "%4.2f", which is
> complete in itself, and then "(height)", which is a constant=20
> string -- you understand what I mean.  Altering the notation=20
> as you suggest would undoubtedly break many, many=20
> applications, so we should guess it is not acceptable.
>=20
> --=20
> Fran=E7ois Pinard   http://www.iro.umontreal.ca/~pinard
>=20