Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 2438 by [email protected]: repr() does not eval() to the same value
http://code.google.com/p/sympy/issues/detail?id=2438

a = Symbol('a')
b = a/(2*a)
print (b, eval(repr(b))) # (1/2, 0)
from __future__ import division
print (b, eval(repr(b))) # (1/2, 0.5)

I guess there is no nice solution because the compact representation 1./2 implies a change from integer to floating point. However, it is still unexpected for repr() to produce something that is actually different. (I found this when extracting part of a printed expression in ipython.) From the docs for repr()

For many types, this function makes an attempt to return a string that would yield an object with the same value when passed to eval(), otherwise the representation is a string enclosed in angle brackets that contains the name of the type of the object together with additional information often including the name and address of the object.

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy-issues?hl=en.

Reply via email to