Have you looked at Sympy? It has a module for generating LaTeX from python code, but it's actually quite a bit more.
Sympy, as you can probably guess from the name, is a python library for symbolic computation.
The Sympy library also includes it's own built-in interpreter (cd to the sympy directory in site-packages, and type ipython at a shell prompt).
With the sympy interpeter you can do things like this:
In [1]: (1/cos(x)).series(x, 0, 10)
Out[1]:
2 4 6 8
x 5⋅x 61⋅x 277⋅x
1 + ── + ──── + ───── + ────── + O(x**10)
2 24 720 8064
In [2]: ((x+y)**2).expand()
Out[2]:
2 2
x + 2⋅x⋅y + y
In [3]: (1/cos(x)).series(x, 0, 10)
Out[3]:
2 4 6 8
x 5⋅x 61⋅x 277⋅x
1 + ── + ──── + ───── + ────── + O(x**10)
2 24 720 8064
# not quite LaTeX--but Sympy can easily generate LaTeX from python code:
>>> from sympy import Integral, latex
>>> from sympy.abc import x
>>> latex(x**2)
'x^{2}'
>>> latex(x**2, mode='inline')
'$x^{2}$'
>>> latex(x**2, mode='equation')
'\\begin{equation}x^{2}\\end{equation}'
I also wanted to generally recommend the Sympy Library--under active development for about four years now and it's improved substantially each year; it's an excellent, mature library for symbolic computation with excellent docs, and an active and helpful community. (Aside from submitting a couple of patches, I am not a Sympy dev/committer, just a user.)