> It makes absolutely no sense to have escaped unicode characters as actual unicode string.
Absolutely no sense? So is a basic Python expression evaluator like this complete nonsense to you?
#!/usr/bin/env python3
try: # Python 2
from Tkinter import Tk, Entry, END
import tkMessageBox as messagebox
except ImportError: # Python 3
from tkinter import Tk, Entry, END, messagebox
import ast
def my_eval(s):
# assume I've implemented this functionality manually...
return ast.literal_eval(s)
root = Tk()
e = Entry(root)
e.insert(END, '"Hell\\xc3\\xb6"') # Assume the user typed has typed in a Python expression, not me
e.pack()
root.bind('<Return>', lambda evt: messagebox.showinfo("Result", repr(my_eval(e.get()))))
root.mainloop()
I get an escaped
string... because that's quite literally what Entry.get() gives me from the text box the user typed into. The simple fact that I got a
string containing Python source code with escape characters makes "absolutely no sense" to you?
Note that that wasn't even my choice! That was the choice of the built-in Python GUI toolkit... distributed by the same folks who decided this string/bytes overhaul was a brilliant idea...