Here is some code that I've found and would like for someone to explain.
If I assign a string to the variable y, evaluate it with the eval function and assign the content to the variable y2, the interpreter returns true.
>>> y = 'a string'
>>> y2 = eval(repr(y))
>>> y == y2
>>> True
Where as using str(y) in this fashion:
>>> eval(str(y))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<string>", line 1
a string
^
SyntaxError: unexpected EOF while parsing
is not allowed. Why is that?