Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63283 > unrolled thread

Re: word replacing in a paragraph

Started byDavid Froger <david.froger@inria.fr>
First post2014-01-06 15:39 +0100
Last post2014-01-06 15:39 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: word replacing in a paragraph David Froger <david.froger@inria.fr> - 2014-01-06 15:39 +0100

#63283 — Re: word replacing in a paragraph

FromDavid Froger <david.froger@inria.fr>
Date2014-01-06 15:39 +0100
SubjectRe: word replacing in a paragraph
Message-ID<mailman.5018.1389019260.18130.python-list@python.org>
Quoting Frank Cui (2014-01-06 15:01:25)
> Hey guys,
> 
> I'm trying to automate a process by initially creating a standard template and
> then replace some text fields with variable values.
> 
> [for example, "DATE" in the paragraph will be replaced by the current date
> value. it doesn't have to be a literal word of "DATE", "DATE" in "TESTDATE" can
> also be replaced.]
> 
> Is there some lightweight built-in or 3rd party  libraries which are good for
> such kind of work ?

Hi Franck,

There is the standard module:
http://docs.python.org/2/library/string.html#template-strings

Or maybe if you need more power, something like jinja2.  It's for Web (HTML
documents), but it can also be used for any kind of document.
http://jinja.pocoo.org/docs/

David

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web