[Python-3000] string.Formatter class

Jim Jewett jimjjewett at gmail.com
Wed Aug 29 01:07:49 CEST 2007


On 8/28/07, Eric Smith <eric+python-dev at trueblade.com> wrote:
> parse(format_string)

>... returns an iterable of tuples
> (literal_text, field_name, format_spec, conversion)

Which are really either

    (literal_text, None, None, None)
or
    (None, field_name, format_spec, conversion)

I can't help thinking that these two return types shouldn't be
alternatives that both pretend to be 4-tuples.  At the least, they
should be

    "literal text"
vs
    (field_name, format_spec, conversion)

but you might want to take inspiration from the "tail" of an
elementtree node, and return the field with the literal next to it as
a single object.

    (literal_text, field_name, format_spec, conversion)

Where the consumer should output the literal text followed by the
results of formatting the field.  And yes, the last tuple would often
be

    (literal_text, None, None, None)

to indicate no additional fields need processing.

-jJ


More information about the Python-3000 mailing list