Author steven.daprano
Recipients steven.daprano
Date 2021-06-09.01:10:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Format strings should allow spaces around keys and indices. This might be as simple as running str.strip() on the contents of curly braces?

Aside from indentation and newlines, in most other contexts whitespace is insignificant. E.g. in subscripting `seq[ index ]`. But format strings treat spaces as part of the index or key, which is surprising.

f-strings, on the other hand, already allow spaces around expressions and keys:

    >>> name = 'Brian'
    >>> f'{ name.upper() }'


    '{ }'.format(30)
    Expect to get '30'
    but get KeyError: ' '

    '{ 0 }'.format(30)
    Expect to get '30'
    but get KeyError: ' 0 '

    '{ x }'.format(x=30)
    Expect to get '30'
    but get KeyError: ' x '

See discussion here:
Date User Action Args
2021-06-09 01:10:05steven.dapranosetrecipients: + steven.daprano
2021-06-09 01:10:05steven.dapranosetmessageid: <>
2021-06-09 01:10:05steven.dapranolinkissue44355 messages
2021-06-09 01:10:05steven.dapranocreate