Compile latex from python
问题 I have made some python function for compiling passed string as pdf file using latex. The function works as expected and has been quite useful, therefore I look for ways to improve it. The code which I have: def generate_pdf(pdfname,table): """ Generates the pdf from string """ import subprocess import os f = open('cover.tex','w') tex = standalone_latex(table) f.write(tex) f.close() proc=subprocess.Popen(['pdflatex','cover.tex']) subprocess.Popen(['pdflatex',tex]) proc.communicate() os.unlink