Thanks. So the only way of doing in a normal Python shell is to use the S function. Does the S function have any limitations compared to the SymPy Live shell?
On Tuesday, February 17, 2015 at 12:07:18 PM UTC-6, Aaron Meurer wrote: > > The SymPy Live shell does some preparsing of the input to prevent 1/3 > from being converted to 0.33333333333. In a normal Python shell, this > does not happen. You should use Rational(1, 3) or S(1)/3. The link > Jason gave explains why this is necessary. > > Aaron Meurer > > On Tue, Feb 17, 2015 at 11:57 AM, Andre Yonadam <[email protected] > <javascript:>> wrote: > > Hi thanks for the reply. I wanted to do a simple division and print it > out. > > For example print("%d", 5/6). The problem is it doesn't return the > formatted > > result like it would in the shell. Do I have to use the S function? > > > > On Tuesday, February 17, 2015 at 11:28:03 AM UTC-6, Ondřej Čertík wrote: > >> > >> Hi Andre, > >> > >> Can you post your Python code? In Python 2.x, 1/3 returns 0, while in > >> Python 3.x, 1/3 returns 0.3333. You can also turn on the Python 3.x > >> behavior on 2.x with a future import. > >> > >> Ondrej > >> > >> On Tue, Feb 17, 2015 at 10:16 AM, Andre Yonadam <[email protected]> > wrote: > >> > I was writing out a Python file by hand and wasn't getting the > symbolic > >> > results only when using default operators. For example, when dividing > >> > 1/3 it > >> > would return a decimal answer while if I used the Integral function > it > >> > would > >> > give me the right result. > >> > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "sympy" group. > >> > To unsubscribe from this group and stop receiving emails from it, > send > >> > an > >> > email to [email protected]. > >> > To post to this group, send email to [email protected]. > >> > Visit this group at http://groups.google.com/group/sympy. > >> > To view this discussion on the web visit > >> > > >> > > https://groups.google.com/d/msgid/sympy/5ba37888-554a-42fd-b961-f38466a729d1%40googlegroups.com. > > > >> > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "sympy" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > Visit this group at http://groups.google.com/group/sympy. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/sympy/7ba91a47-6809-4aef-a693-db77e3265ce9%40googlegroups.com. > > > > > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/3ebf85cf-e5c2-4919-939a-9be4fa4bf71c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
