[issue44355] Allow spaces in format strings

2021-07-13 Thread Jean Abou Samra
Jean Abou Samra added the comment: Maybe leave the current state, keeping backwards compatibility, but improve the error message by adding "perhaps you wanted no spaces in the format field?" when the_field.replace(" ", "") would be valid? -- nosy: +Jean_Abou_Samra __

[issue44355] Allow spaces in format strings

2021-06-09 Thread Eric V. Smith
Eric V. Smith added the comment: See msg395383 for how it's an incompatible change even to .format(). In the 15 years since I implemented .format(), this is the first I've ever heard of someone being confused by adding extra spaces. I don't think it's worth changing this. -- __

[issue44355] Allow spaces in format strings

2021-06-09 Thread Steven D'Aprano
Steven D'Aprano added the comment: I agree that we cannot make the syntax of format string identifal to f-strings. F-strings support arbitrary expressions, while format strings support only a small subset of possible identifiers. My comment was not to make format strings identical to f-string

[issue44355] Allow spaces in format strings

2021-06-09 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: Syntax of format strings cannot be the same as in f-strings. {0} means the first positional argument in format string an integer literal 0 in f-string. {a[x]} means the value of literal string key "x" of keyword argument a in format string, and indexing va

[issue44355] Allow spaces in format strings

2021-06-08 Thread Eric V. Smith
Eric V. Smith added the comment: The problem with this change is that it wouldn't be backward compatible. I'm not sure how many people it would affect, but probably more than zero. >>> str.format('{ 0 }', **{' 0 ': 42}) '42' >>> str.format('{ }', **{' ': 43}) '43' Does that mean it can't be

[issue44355] Allow spaces in format strings

2021-06-08 Thread Cameron Simpson
Change by Cameron Simpson : -- nosy: +cameron ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.py

[issue44355] Allow spaces in format strings

2021-06-08 Thread Eric V. Smith
Change by Eric V. Smith : -- nosy: +eric.smith ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.p

[issue44355] Allow spaces in format strings

2021-06-08 Thread Steven D'Aprano
New submission from Steven D'Aprano : 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[