What is the most pythonic way to build up large strings?

Roy Smith roy at panix.com
Sat Feb 8 07:15:56 EST 2014


In article <3157d511-48d1-4e4d-be4c-2c461fc17466 at googlegroups.com>,
 Rustom Mody <rustompmody at gmail.com> wrote:

> On Saturday, February 8, 2014 1:11:53 PM UTC+5:30, cstru... at gmail.com wrote:
> > I am writing a couple of class methods to build up several lines of html.  
> > Some of the lines are conditional and most need variables inserted in them. 
> >  Searching the web has given me a few ideas.  Each has its pro's and cons.
> 
> For creating html the method of choice is a template engine -- cheetah, mako 
> and a dozen others

Absolutely agree.  No need to reinvent a wheel which has already been 
invented in so many shapes, sizes, and colors.

We use http://jinja.pocoo.org/, but like Rustom said, there are many to 
pick from.  Any of them is likely to be a better solution than what you 
would roll yourself.



More information about the Python-list mailing list