Texcaller Python interface
import texcaller
texcaller.convert(source, source_format, result_format, max_runs)  # returns a pair (result, info)

These Python functions are simple wrappers around the Texcaller C interface library functions, making TeX typesetting easily accessible from Python.

# coding: UTF-8

import texcaller

latex = ur'''\documentclass{article}
Hello world!

pdf, info = texcaller.convert(latex, 'LaTeX', 'PDF', 5)
print 'PDF size:     %.1f KB' % (len(pdf) / 1024.0)
print 'PDF content:  %s ... %s' % (pdf[:5], pdf[-6:])

s = u'Téxt → "with" $peciäl <characters>'

print 'Original:  %r' % s
print 'Escaped:   %r' % texcaller.escape_latex(s)
Beware of \u

Unfortunately, Python always interprets \uXXXX sequences in unicode strings (even in raw unicode strings), which interferes badly with common LaTeX commands such as \usepackage{}. This means every backslash \ which is followed by the character u needs to be escaped via \u005c, which looks really strange:

latex = ur'''
\begin{document} Hello math! \end{document}

Fortunately, this problem is easily solved by using raw byte strings, and converting those to unicode strings via the decode() method:

latex = r'''
\begin{document} Hello math! \end{document}