A very good programming guideline is separation of logic from presentation.
This is done in professional Web development (see e.g. Django). If you think not about html pages, but pdf, the answer is the same.
The more you mix your code logic with presentation, the more difficult it is to support and modify that. Are you planning to re-launch all your computations if you want to change a caption of one table? Are you going to reprocess all rendering when you want to change some internal implementation of a function?
That's why I think that calling Python from LaTeX or creating LaTeX strings from Python is in general not a very good idea.
It is possible though when you store logic in one place (Python files) and presentation in another place (LaTeX templates), and join them in the third place (aka Model-Template-View or Model-View-Controller architecture).
Unfortunately, it is not straightforward to just take Jinja2 (as @user573 proposed) and render LaTeX templates with that: you have to define the template language for LaTeX (which is not so hard). Then you have to run
pdflatex (or other command) via Python's
subprocess module. I also run
pdftoppm to generate png images from pdfs (those are easier to slide and can be used in Web, if one needs that). I don't copy the exact code here (see yourself the link below), because it would lead to further questions.
I created a data analysis framework in Python, which allows to easily generate many figures with LaTeX quality, while keeping your data, logic and presentation separate. It can be used outside data analysis, because it is a general architectural framework (you can render figures, or tables, or any text - there are no artificial limitations for that). It follows functional programming style (and in some places object-oriented approach). You can check examples and the approach in the first part of Lena tutorial. If an "architectural framework" sounds frightening, I should add that the 1st part would already be enough to create many plots.
UPD: I forgot to mention that Lena doesn't recreate already produced plots if they were not changed (neither the data, nor the template). This is a useful optimization when creating many figures (and adding new ones).