New submission from Anthon van der Neut:

Since 3.4.1, string.Formatter() accepts empty keys {}. If these are nested they 
give different results from explicitly numbered, where the same arguments 
applied  "".format() give the expected results:

    from string import Formatter

    f = Formatter()

    fmt0 = "X {:<{}} {} X"
    fmt1 = "X {0:<{1}} {2} X"

    for fmt in [fmt0, fmt1]:
        x = f.format(fmt, 'ab', 5, 1)
        y = fmt.format(   'ab', 5, 1)
        print(x)
        print(y)
gives:

    X ab    5 X
    X ab    1 X
    X ab    1 X
    X ab    1 X
of which the first line is incorrect.

----------
components: Library (Lib)
messages: 250253
nosy: anthon
priority: normal
severity: normal
status: open
title: string.Formatter accepts empty fields but displays wrong when nested
type: behavior
versions: Python 3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25034>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to