This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: string.Formatter class not allowing {.field}
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.8
process
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 2022-04-11 14:59 by admin.

Messages (2)
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))
msg405615 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-11-03 13:39
I think this is a dupe of issue 27307.
History
Date User Action Args
2022-04-11 14:59:47adminsetgithub: 88662
2021-11-03 13:39:08eric.smithsetmessages: + msg405615
2021-06-23 12:01:57corona10setnosy: + corona10
2021-06-23 08:11:38eric.smithsetnosy: + eric.smith
2021-06-23 07:26:04avdwoudecreate