You can transform an expression into a Python callable function with lambdify
In [1]: f = lambdify(x, 100-2*x) In [2]: f(2) Out[2]: 96 On Mon, Jan 14, 2013 at 5:14 PM, Ben Lucato <[email protected]> wrote: > Hi I have looked through the docs and other places online, but I haven't > found an answer! > > Currently when working with functions I do this: > > from sympy import * > f = Function('f') > x = Symbol('x') > f = 100 - 2 * x > > to evaluate f I have to do this: > f.subs({x: 2}) > >>> 96 > > which is a pain. Is there some way to define my function such that I can > do: > f(2) > >>> 96 > ??? > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/sympy/-/By7WV9mZh8wJ. > 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.
