[Python-3000] String formating operations in python 3k

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Apr 4 03:27:41 CEST 2006


Barry Warsaw wrote:

> I don't much like the $"" prefix

This was discussed during the last round of formatting
wars, and the conclusion was that having $ both
inside and outside the string would be too visually
confusing.

> I don't see a good
> way to marry the rich coercion of %-substitution with the simplicity of
> $-substition.

If I were designing a formatting system from scratch,
I think I'd separate the issue of formatting numbers into
strings from the issue of inserting strings into other
strings. So instead of

   "Answer no. %5d is %8.3f" % (n, x)

you would say something like

   subst("Answer no. {1} is {2}", format(i, 'd', 5), format(x, 'f', 8, 3))

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiam!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-3000 mailing list