On 2/24/2015 10:49 AM, Guido van Rossum wrote:
I like the \x07 solution.
The more I think about it, the more I think this is a sufficient solution. People that use repr to get a Python-compatible string syntax for further program use get one. People that see them in an error message are much less likely to be fooled into thinking it is two characters, because they are thinking of it as two characters to start with.
On the other hand, I have a directory full of "throw away" experimental source files named x01, x02, x03, ... :)
And I suppose extensive use of certain characters in repr in intermediate or archived data could make such data grow in size.
And while \t and \n are very commonly used escapes, maybe string repr could have a special function called .I_promise_not_to_report_issues_when_I_use_backslash_escapes_in_character_literals_and_get_confused() which would switch back from \x07 to \t and \x0a to \n, etc. This would be callable only from __main__ :)