[Python-3000] More PEP 3101 changes incoming

Brandon Craig Rhodes brandon at rhodesmill.org
Fri Aug 3 04:14:58 CEST 2007


"Guido van Rossum" <guido at python.org> writes:

> My personal suggestion is to stay close to the .NET formatting language:
>
>   name_specifier [',' width_specifier] [':' conversion_specifier]

A problem is that this format requires brute memorization to remember
where to put things.  If letters were used to prefix specifications,
like "w" for width and "p" for precision, one could write something
like:

   >>> 'The average is: {0:w8p2} today.'.format(avg)
   'The average is:     7.24 today.'

This would give users at least a shot at mnemonically parsing - and
constructing - format strings, and eliminate the problem of having to
decide what goes first.

If, on the other hand, all we have to go on are some commas and
colons, then I, for one, will probably always have to look things up -
just like I always did for C-style percent-sign format specifications
in the first place.

-- 
Brandon Craig Rhodes   brandon at rhodesmill.org   http://rhodesmill.org/brandon


More information about the Python-3000 mailing list