I think Symbol is an exception because it is an Atom, signaling the base case of the recursion. Ditto for subclasses of Number. Actually, I don't know if we ever decided how that should work (cf issue 1206).
Also, technically srepr doesn't give a rebuildable expression, because it does not include assumptions, but that's a separate issue. Aaron Meurer On May 20, 2012, at 3:22 PM, "[email protected]" <[email protected]> wrote: > From issue 2070. However even Symbol is not rebuildable like this. > > On the other hand Symbol is rebuildable with eval(srepr(obj)). This is > the case because in ReprPrinter we have: > > def _print_Symbol(self, expr): > return "%s(%s)" % (expr.__class__.__name__, self._print(expr.name)) > > Obviously if `name` was part of `args` this would have worked > automatically. However `name` is a string so it can not be in args. > > So which is more important? obj.__class__(*obj.args) == obj or having > everything in args being an instance of Basic? It does not seem > possible to have both. > > By the way ReprPrinter does not look sustainable if it has to do > special cases for each class. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" 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?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" 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?hl=en.
