On 2015-08-11 00:26, Victor Stinner wrote: > Le mardi 11 août 2015, Eric V. Smith <eric at trueblade.com > <mailto:eric at trueblade.com>> a écrit : > > It sounds like you want to disallow leading spaces just to > disallow this one type of expression. > > > I would like to reduce the number of subtle differences between > f-string and str.format(). > I'm a little bit surprised at seeing this: >>> '{0}'.format('foo') 'foo' >>> '{ 0}'.format('foo') Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: ' 0' >>> '{a}'.format(a='foo') 'foo' >>> '{ a}'.format(a='foo') Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: ' a' In some other cases, leading and trailing spaces are ignored: >>> int(' 0 ') 0 Outside string literals, they're also ignored. But, then: >>> '{-1}'.format('foo') Traceback (most recent call last): File "<stdin>", line 1, in <module> KeyError: '-1' It's a string key, even though it looks like an int position.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4