Maybe this then? sage: from sympy import * sage: Symbol("x") x sage: f = 3*x^2 sage: str(f.as_basic()) '3*x**2'
On Sat, May 9, 2009 at 7:56 AM, Laurent <moky.m...@gmail.com> wrote: > > >> >> sage: str(latex(g)) >> '{3 {x}^{2} }' >> >> what you want? >> > I would prefer 3*(x**2) > {3 {x}^{2} } > is not a valid pstricks's syntax, and I don't see how to manipulate it > in order to get something valid. > Maybe I can make the replacement { -> ( and } ->), but I fear some side > effect of the LaTeX syntax for \sin, \exp or others ... > Moreover, I don't know how to add the missing multiplicative signes > (like the 3 which has to multiplicate x^2 here) > > Now, the string "3*(x**2)" is a valid syntax for pstricks (up to > replacement ** -> ^, which is trivial) > > > Making some tests, I remarked the following : > > > 13:45:19 ~ >$ sage > ---------------------------------------------------------------------- > | SAGE Version 3.0.5, Release Date: 2008-07-11 | > | Type notebook() for the GUI, and license() for information. | > ---------------------------------------------------------------------- > > sage: var('x') > x > sage: f(x)=x**3 > sage: f(x) > x^3 > sage: print f(x) > > 3 > x > sage: > > > The output of f(x) is what I want to catch in a string (python). > > The following does not work, and I understand (more or less) why : > > s = "x**3" > var('x') > f = eval(s) > t = f(x).replace("3","hello") > print t > > The expected result was > x^hello > or > x**hello > or, better : > x^(hello) > > > Have a good day > Laurent > > > > > --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---