code style/efficiency question: text file templates

Dave Cole djc at
Mon Aug 5 00:18:46 EDT 2002

>>>>> "Chris" == Chris  <<>> writes:

Chris> simple stuff here.  If I want to generate 100 subtly different
Chris> templated HTML pages that are each about 150 lines long, do you
Chris> think it better (efficiency and/or style) to create one file,
Chris> then read, modify necessary parts, and save as new file name,
Chris> or to run through a loop of 150 file.write('') for each file
Chris> name?

Chris> So either I read the 150 lines and replace strings, or write
Chris> 150 lines.

Chris> The page to page deviations are minor (one image name, one
Chris> caption string from image name).  I was assuming I would do the
Chris> latter, but the former occurred to me tonight.  Either way I
Chris> obviously have to devise and type the HTML code once,
Chris> obviously.

Chris> Saving femtoseconds isn't critical, but I'd like to get some
Chris> real programmers' views on which is better and maybe learn some
Chris> higher principle.

Use the programmer time as the scarce resource and use a templating
system.  There are lots of different templating systems to choose

- Dave


More information about the Python-list mailing list