Mathematica-style notebook in Python

David E. Konerding DSD staff dek at pabst.lbl.gov
Fri Feb 13 12:15:20 EST 2004


In article <1f0bdf30.0402122327.13f7122f at posting.google.com>, Erik Lechak wrote:
> rick_muller at yahoo.com (Rick Muller) wrote in message news:<5eb8fb88.0402121313.6a48602b at posting.google.com>...
>> I was wondering whether anyone has considered writing a
>> Mathematica-style notebook in Python. I use Python to do a lot of
>> scientific analysis, and I really like it's power. But what I always
>> envy about my friends who use Mathematica is the notebooks they
>> generate, which contain plots, annotations, and other information, in
>> a format that can be reloaded easily when you want to check your work.
>> 
>> Before I start doing something like this, has anyone else considered
>> it?

You could use my "Py-ML" library which provides Mathematica support in Python.

http://py-ml.sourceforge.net/

You should (in theory- I never tried it) be able to create notebooks programmatically
and control them from Python.

Here's an example of using Py-ML:

>>> function = MathematicaFunction("Plus",MathematicaInteger(1),[MathematicaSymbol("x")]) 

>>> print function
Plus[1,x] 

>>> expression = MathematicaExpression(function)
>>> e = m.evaluate(expression)
>>> result= m.process() 


>>> Plus = MathematicaFunction("Plus")
>>> function = Plus(1+"x")
>>> print function
Plus[1,x]
or
>>> x=MathematicaSymbol("x")
>>> function = 1+x
>>> print function
Plus[1,x] 


More complicated functions, such as integrals, are entered easily.
The integral of x^2 with x varying from 0 to 2:
function = Integrate(Power("x",2), List("x",0,2)) 



... unfortunately, I don't really use Mathematica any more (it's just too expensive and it never simplified
any interesting integrals for me), so Py-ML isn't really an active software project any more.
There are a lot of interesting opportunities for further development.

Dave



More information about the Python-list mailing list