Terry J. Reedy <[email protected]> added the comment:
An f-string is equivalent to a format string and call. The exact details are
not important.
An field with no value is an error either way. (I prefer the compile-time
exception.)
>>> f'{}a'
SyntaxError: f-string: empty expression not allowed
>>> '{}a'.format()
Traceback (most recent call last):
File "<pyshell#20>", line 1, in <module>
'{}a'.format()
IndexError: tuple index out of range
>>> 'abc'.format()
'abc'
>>> f'abc'
'abc'
I agree that neither needs a warning. I actually think the useless call is
worse than the unneeded prefix.
SyntaxWarnings are rare. Invalid escapes are now errors.
>>> '\o'
SyntaxError: invalid escape sequence \o
----------
nosy: +terry.reedy
resolution: -> rejected
stage: -> resolved
status: open -> closed
type: -> enhancement
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue37068>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com