ANNOUNCE: PySymbolic - Doing Symbolics in Python

Alex Martelli aleaxit at yahoo.com
Thu Oct 12 16:44:37 EDT 2000


"Pearu Peterson" <pearu at ioc.ee> wrote in message
news:39E5F414.5A2457E3 at ioc.ee...
> Pearu Peterson wrote:
>
> > In addition, I am thinking of the following syntax examples in Python:
> >         Diff(x*x,x)
> >         Integrate(a*x,x=[c,d])
    [snip]
> > It is not possible to get this kind of a look for Python and it
> > looks pretty good to me.
>
> I really meant, "It is possible to get .."

Python evaluates the arguments before passing them to any
callable-object.  So, for example, if you write
    Diff(x*x, x)
the x*x multiplication will take place before Diff ever sees
the argument -- it will only get a number (the square of
x), not the information that it was obtained by an expression
of a given form.  Similarly for x -- Diff will get the value,
not the variable-name.

You will probably need to quote your args...:

    Diff('x*x', 'x')


Alex






More information about the Python-list mailing list