You could try using the evaluate=False flag in Mul: In [4]: Mul(2, S(1)/4, evaluate=False) Out[4]: 2 ─ 4
Aaron Meurer On Aug 6, 2009, at 3:43 PM, James Pearson wrote: > I'm working on an online homework system, where I'm using SymPy to > store data, as well as do all of the hard calculations when a test > for equality is needed. This ends up being a far more basic usage > of the library than most people here, it seems, from reading over > the list. > > One thing that I'm having trouble with is in storing equation, > fractions, or other mathy things. For instance, perhaps I have the > fraction 6/4; if I create a Rational out of it, it becomes 3/2, > which is particularly unfortunate if the question asks the student > to reduce the fraction! I could store it as a string, but I like > being able to use it as a sympy object, in particular, feeding it to > printing.latex. A similar thing happens with equations; all of the > menial work that is exactly what I'm trying to test gets done > automagically by sympy. > > What would you suggest? Would subclassing Rational (and other > appropriate classes) be the best way to get the behavior I want? > > Thanks for all of the work on this library, btw. I thought I was > going to have to write reduction and latex-generation functions > myself. Silly me should have learned by now that there's a Python > library (or 2 or 3) for everything. > > -- > James Pearson > -- > The best way to predict the future is to invent it. > - Alan Kay > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
