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


Groups > comp.lang.python > #63291

Re: word replacing in a paragraph

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <prvs=076009678=jeanmichel@sequans.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.118
X-Spam-Level *
X-Spam-Evidence '*H*': 0.77; '*S*': 0.00; 'automate': 0.07; 'literal': 0.09; 'cc:addr:python-list': 0.11; 'template': 0.14; 'guys,': 0.16; 'code.': 0.18; 'hey': 0.18; 'variable': 0.18; 'trying': 0.19; 'value.': 0.19; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'replace': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; "i'm": 0.30; 'libraries': 0.31; 'values.': 0.31; 'text': 0.33; '-----': 0.33; 'there': 0.35; 'thanks': 0.36; 'should': 0.36; 'example,': 0.37; 'thank': 0.38; 'initially': 0.38; 'you.': 0.62; 'advanced': 0.63; 'information': 0.63; 'kind': 0.63; 'such': 0.63; 'received:194': 0.64; 'more': 0.64; 'notice:': 0.67; 'frank': 0.68; 'person,': 0.68; 'privileged.': 0.69; 'disclose': 0.74; 'lightweight': 0.84; 'medium.': 0.91
X-IronPort-AV E=Sophos;i="4.95,613,1384297200"; d="scan'208";a="2303819"
X-Virus-Scanned amavisd-new at zimbra.sequans.com
Date Mon, 6 Jan 2014 16:56:01 +0100 (CET)
From Jean-Michel Pichavant <jeanmichel@sequans.com>
To Frank Cui <ycui@outlook.com>
In-Reply-To <BAY176-W84F6BD350557828CDAD2DDAB70@phx.gbl>
Subject Re: word replacing in a paragraph
MIME-Version 1.0
X-Mailer Zimbra 7.2.4_GA_2900 (ZimbraWebClient - GC31 (Win)/7.2.4_GA_2900)
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5024.1389023832.18130.python-list@python.org> (permalink)
Lines 19
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389023832 news.xs4all.nl 2974 [2001:888:2000:d::a6]:59846
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63291

Show key headers only | View raw


----- Original Message ----- 

> 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 ?

> Thanks
> Frank

Jinja2 would be able to do it, with very few line of code.
And you get all the features provided by a template engine should you need them to build more advanced templates.

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: word replacing in a paragraph Jean-Michel Pichavant <jeanmichel@sequans.com> - 2014-01-06 16:56 +0100

csiph-web