[Python-3000] PEP 3101 update

Guido van Rossum guido at python.org
Thu Jun 22 18:54:51 CEST 2006

On 6/22/06, Nick Coghlan <ncoghlan at gmail.com> wrote:
> However, I realised that there's an approach that is aesthetically pleasing
> and doesn't require using str() for this - simply consider the leading '{0:'
> and trailing '}' to be implicit if there are no braces at all in the supplied
> format string.

-1. Implicit is better than explicit. It would encourage Python to
guess when there are no braces but there is a format argument, instead
of throwing an exception.

To Talin: I'm all for a way to say blah(x, "2.2g") instead of the more
verbose "{2.2g}".format(x). In fact it would probably be great if the
latter was officially defined as a way to spell the former combined
with literal text:

  "foo{2.2g}bar{3.3f}spam".format(x, y)

is shorter and mor readable than

  "foo" + blah(x, "2.2g") + "bar" + blah(y, "3.3f") + "spam"

What I object to is only the spelling of blah(x, f) as str(x, f).
Perhaps a static string method; but probably better some other
built-in or something in a new stdlib module.

--Guido van Rossum (home page: http://www.python.org/~guido/)

More information about the Python-3000 mailing list