[issue29104] Left bracket remains in format string result when '\' preceeds it
Eric V. Smith
report at bugs.python.org
Thu Dec 29 07:45:48 EST 2016
Eric V. Smith added the comment:
I'm not sure this counts as an error. The backslash means to treat the next character literally, which this does. And since \{ is not a valid escape sequence, it keeps both characters, exactly like:
>>> '\c'
'\\c'
Furthermore, since unknown escape sequences are deprecated, this usage is going to be an error in the future. You can see this now with -Werror:
$ python.exe -Werror
Python 3.6.0b1+ (3.6:87de1f12c41c+, Sep 16 2016, 07:05:57) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> f'\{10}'
DeprecationWarning: invalid escape sequence '\{'
>>> '\c'
DeprecationWarning: invalid escape sequence '\c'
>>>
Since this works as I expect it to now, and since it will become an error in the future, I don't think any change is warranted.
----------
assignee: -> eric.smith
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue29104>
_______________________________________
More information about the Python-bugs-list
mailing list