Le dimanche 29 mai 2011 à 08:25 -0700, Vinzent Steinberg a écrit : > On 28 Mai, 17:40, Ronan Lamy <[email protected]> wrote: > > I don't care about that, because we don't put stuff inside containers > > that often, because I usually want the repr when I look at .args, and > > because the only shell I really care about is ipython, which prints this > > nicely in any case. > > I care about pure python shells. However, I could live with it if > there was a trivial way to setup printing as in isympy (calling > init_printing() probably already does this). > There is:
ronan@ronan-desktop:~/Projets/sympy-git$ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> from sympy import * >>> import sys >>> sys.displayhook = pprint >>> class A(object): ... def __str__(self): return "A" ... >>> A() A >>> [A()] [A] >>> str([A()]) [<__main__.A object at 0x9d2024c>] > > What matters is that: > > * we can't change it > > * people new to sympy who know Python expect it > > * there is a lot of code outside sympy that takes this behaviour for > > granted and works with/around it. > > On the other hand, eval(repr(x)) == x does not hold in general, see > for example lambda, functions, numpy arrays etc. Sure. But what I meant by "this behaviour" is the fact that str() is supposed to be the nice, human-friendly representation of the object, while repr() shows what's actually inside the object, and that the str() of built-in containers isn't actually nice enough for most uses. -- 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.
