Title: string.Formatter class not allowing {.field}
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: avdwoude, corona10, eric.smith
Priority: normal Keywords:

Created on 2021-06-23 07:26 by avdwoude, last changed 2021-06-23 12:01 by corona10.

Messages (1)
msg396383 - (view) Author: Aschwin (avdwoude) Date: 2021-06-23 07:26
I expected the custom Formatter to behave the same as the normal "".format() function, but unnamed args or not supported.
Below is an example, which fails at a KeyError.

from string import Formatter

class test():
    def __init__(self):
        self.msg = "OK"
t = test()

print("Normal format() is {.msg}".format(t))

f = Formatter()
print(f.format("Formatter.format() is {.msg}", t))
Date User Action Args
2021-06-23 12:01:57corona10setnosy: + corona10
2021-06-23 08:11:38eric.smithsetnosy: + eric.smith
2021-06-23 07:26:04avdwoudecreate