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

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Apr 4 04:28:39 CEST 2006


Ian Bicking wrote:

> FWIW, I suspect I'd be much more likely to use named %'s with .format() 
> than with %; which is probably good, since named markers are more 
> flexible.

If we're going to encourage use of named arguments
(which I think we should) I think we also need to
get rid of the need for %(foo)s constructs, which
are extremely error-prone and hard to read.

I'm -0.7 on having two different formatting
styles (one using % and the other using $) with
partially-overlapping functionality. In Py3k
there should be OOWTDI.

I'm also not all that keen on $, either inside
or outside the string. It seems to me that
something like

   "User {user} has printed {n} pages"

sets off the parameters from the rest of the
string more readably than

   "User $user has printed $n pages"

There are various ways that the traditional
%-formatting parameters could be incorporated,
e.g.

   "Answer {num:d,5} is {result: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