[Python-3000] PEP 3101 Updated (original) (raw)

Guido van Rossum guido at python.org
Thu Aug 23 01:52:20 CEST 2007


On 8/22/07, Eric Smith <eric+python-dev at trueblade.com> wrote:

James Thiele wrote: > In the section "Explicit Conversion Flag" of PEP 3101 it says: > > Currently, two explicit conversion flags are recognized: > > !r - convert the value to a string using repr(). > !s - convert the value to a string using str(). > -- > It does not say what action is taken if an unrecognized explicit > conversion flag is found.

My implementation raises a ValueError, which I think is the desired behavior: >>> "{0!x}".format(1) Traceback (most recent call last): File "", line 1, in ValueError: Unknown converion specifier x

You raise ValueErrors for other errors with the format, right? If there's a reason to be more lenient, the best approach would probably be to interpret it as !r.

I agree the PEP should be explicit about this.

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



More information about the Python-3000 mailing list