Printing

str, srepr, and a latex string.

str, srepr, and latex are different views of the same expr. Print the latex as a string — do not expect a rendered formula here.

Goal

Print three representations of (x^2-1)/(x-1).

import sympy as sp
x = sp.symbols('x')
e = (x ** 2 - 1) / (x - 1)
print(str(e))
print(sp.srepr(e))
print(sp.latex(e))
import sympy as sp
print(sp.pretty(sp.sqrt(8)))
import sympy as sp
print(sp.latex(sp.Integral(sp.symbols('x') ** 2, sp.symbols('x'))))
import sympy as sp
print(sp.simplify((sp.symbols('x') ** 2 - 1) / (sp.symbols('x') - 1)))