This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients Jim Fasarakis-Hilliard, eric.smith, serhiy.storchaka, vstinner
Date 2017-01-03.13:12:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The PEP 498 should be updated to define the expected behaviour of f'\{5}':

+        self.assertEqual(f'\{6*7}', '\\42')
+        self.assertEqual(f'\\{6*7}', '\\42')
+        self.assertEqual(fr'\{6*7}', '\\42')
+        AMPERSAND = 123
+        self.assertEqual(f'\N{AMPERSAND}', '&')
+        self.assertEqual(f'\\N{AMPERSAND}', '\\N123')
+        self.assertEqual(fr'\N{AMPERSAND}', '\\N123')
+        self.assertEqual(f'\\\N{AMPERSAND}', '\\&')

I'm not sure that I like this behaviour.

f'\\N{AMPERSAND}': reading a local variable looks like a typo or a security vulnerability, rather than a nice feature.

IMHO if you want an anti-slash (\) in the output string, it *must* be written "\\" since we *do* interpret other escape sequences:

* f'\n' returns '\n', the newline character U+000A
* f'\N{Snowman}' returns the nice snowman character U+2603 (☃)
* etc.

What is the issue with having to write "\\{10}" to get "\\10" string? It's less error prone.
Date User Action Args
2017-01-03 13:12:57vstinnersetrecipients: + vstinner, eric.smith, serhiy.storchaka, Jim Fasarakis-Hilliard
2017-01-03 13:12:57vstinnersetmessageid: <>
2017-01-03 13:12:57vstinnerlinkissue29104 messages
2017-01-03 13:12:57vstinnercreate