[issue44683] String formatting

2021-07-20 Thread Dennis Sweeney
Dennis Sweeney added the comment: If I understand correctly, this shows the behavior you're objecting to: >>> class A: ... def __getitem__(self, key): ... print(f"{key = }") ... return "apple" ... ... >>> '{0[1]}'.format(A()) # passes an integer key = 1 'apple' >>> '{

[issue44683] String formatting

2021-07-20 Thread Mykyta
Change by Mykyta : Removed file: https://bugs.python.org/file50166/1.png ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscrib

[issue44683] String formatting

2021-07-20 Thread Mykyta
New submission from Mykyta : The formatting does not work correctly. I have a dict with string representations of integers as keys, such as {'1': 'a'} and trying to format it this way: '{0[1]}' and KeyError occurs. But I think it should not as '{0[a]}'.format(a) works properly with a = {'a':