ANNOUNCE: PySymbolic - Doing Symbolics in Python
aleaxit at yahoo.com
Fri Oct 13 09:00:25 CEST 2000
"Tim Peters" <tim_one at email.msn.com> wrote in message
news:mailman.971399443.5181.python-list at python.org...
> > Diff(x*x,x)
> [Alex Martelli]
> > 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
> > Diff('x*x', 'x')
> I believe Pearu has already discovered "the right way" to get the effect
> he's after in Python: define a class for symbolic variables, and precede
> his examples by, e.g.,
> x = Symbolic('x')
> a = Symbolic('a')
> and so on. Then define Symbolic.__add__ etc to build up an expression
Aha, I see -- thanks for pointing it out, I had a blind spot there. Funny
how one gets these blind-spots at times!
> That slick trick has been rediscovered several times in Python, and I've
> found it quite satsifying in practice the few times I've used it.
> beats-incessant-quoting-anyway-ly y'rs - tim
Definitely. Once again, Python's simplicity, dynamicity, regularity,
combine to make the seemingly-impossible into the actually-pretty-easy.
What a language...!
More information about the Python-list