Hi,
I'm creating a small application in Python that uses lists and
dictionaries to create a rudimentary database. I'd like to create some
"fill-in-the-blanks" reports from this data, ideally by taking an RTF
or plaintext file as a template and replacing placeholder tags with my
data.
Are there any good pre-written systems that would allow me to do this?
Thanks,
- QS Computing. 13 1375 qs*********@gmail.com wrote: Hi,
I'm creating a small application in Python that uses lists and dictionaries to create a rudimentary database. I'd like to create some "fill-in-the-blanks" reports from this data, ideally by taking an RTF or plaintext file as a template and replacing placeholder tags with my data. Are there any good pre-written systems that would allow me to do this?
Maybe the built-in string interpolation is sufficient?
print "Hello %(name)s" % dict(name="Peter Pan")
diez
Diez B. Roggisch wrote: qs*********@gmail.com wrote:
Hi,
I'm creating a small application in Python that uses lists and dictionaries to create a rudimentary database. I'd like to create some "fill-in-the-blanks" reports from this data, ideally by taking an RTF or plaintext file as a template and replacing placeholder tags with my data. Are there any good pre-written systems that would allow me to do this?
Maybe the built-in string interpolation is sufficient?
print "Hello %(name)s" % dict(name="Peter Pan")
Else you may want to look at:
- http://www.python.org/doc/2.4.2/whatsnew/node5.html
- empy : http://www.alcyone.com/pyos/empy/
- cheetah : http://www.cheetahtemplate.org/
HTH
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Thanks, it looks like empy is what I need.
Diez B. Roggisch wrote: qs*********@gmail.com wrote:
Maybe the built-in string interpolation is sufficient?
print "Hello %(name)s" % dict(name="Peter Pan")
Or in recent pythons, the built-in string templating system (see http://docs.python.org/lib/node109.html) from string import Template d = dict(name="Barney") s = Template("Hello $name") s.substitute(d)
'Hello Barney' qs*********@gmail.com wrote: Hi,
I'm creating a small application in Python that uses lists and dictionaries to create a rudimentary database. I'd like to create some "fill-in-the-blanks" reports from this data, ideally by taking an RTF or plaintext file as a template and replacing placeholder tags with my data. Are there any good pre-written systems that would allow me to do this?
Thanks, - QS Computing.
It may be overkill for your application but if you are looking for
high quality .PDF output this combination works:
ReportLab PageCatcher - reads .PDF background templates (note: not free)
ReportLab - allows you to write on top of the .PDF template to produce
a .PDF file as output.
The results are a very high quality .PDF output document.
-Larry Bates
<qs*********@gmail.com> wrote: Hi,
I'm creating a small application in Python that uses lists and dictionaries to create a rudimentary database. I'd like to create some "fill-in-the-blanks" reports from this data, ideally by taking an RTF or plaintext file as a template and replacing placeholder tags with my data. Are there any good pre-written systems that would allow me to do this?
I have a certain fondness for the first over-100-lines module I wrote
for Python, which eventually resulted in: http://aspn.activestate.com/ASPN/Coo...n/Recipe/52305
and while I haven't checked its descendant: http://aspn.activestate.com/ASPN/Coo.../Recipe/465508
it may have important enhancements. There are also a couple of
variations on the web that are specialized for XML and HTML (search for
yaptu), but the generic one should work better for RTF and TXT.
Alex qs*********@gmail.com wrote: Thanks, it looks like empy is what I need.
:-)
--
Erik Max Francis && ma*@alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
The object of war is not to die for your country but to make the
other bastard die for his. -- Gen. George Patton
Actually, that looks even better that EmPy for what I need. I will try
out these suggestions and then see what seems best.
Thanks very much.
>>>>> "Alex" == Alex Martelli <al*****@yahoo.com> writes:
Alex> I have a certain fondness for the first over-100-lines
Alex> module I wrote for Python, which eventually resulted in:
As well you should! YAPTU powers the entire matplotlib website
(screenshots, FAQ, what's new, etc), as evidenced by the "Powered by
YAPTU" co-branding on the bottom of every page http://matplotlib.sf.net
with src (*.html.template) at http://svn.sourceforge.net/viewcvs.c.../trunk/htdocs/
I must confess though that the prehistoric YAPTU version I use comes
in at only 78 lines, so it is clearly time for me to upgrade. I rely
on it so much I even wrote a debian ubuntu package for local use, as
twisted as that may seem. I definitely need to check out the latest
version!
JDH qs*********@gmail.com wrote: Hi,
I'm creating a small application in Python that uses lists and dictionaries to create a rudimentary database. I'd like to create some "fill-in-the-blanks" reports from this data, ideally by taking an RTF or plaintext file as a template and replacing placeholder tags with my data. Are there any good pre-written systems that would allow me to do this?
Another option is the 'embedded_code.py' module used by `Firedrop2
<http://www.voidspace.org.uk/python/firedrop2/>`_ and `rest2web
<http://www.voidspace.org.uk/python/rest2web/>`_.
It takes a text string as input and a namespace (dictionary) as input
and returns a text string.
It replaces single placeholders of the form :
<% name %>
It also executes chunks of embedded code in the namespace, and replaces
them with whatever the code prints to stdout. These are of the form :
<#
print name
if name2.startswith('something'):
print name2
#>
This is very useful for simple templating.
All the best,
Fuzzyman http://www.voidspace.org.uk/python/shareware.shtml
Thanks, - QS Computing. qs*********@gmail.com enlightened us with: I'm creating a small application in Python that uses lists and dictionaries to create a rudimentary database. I'd like to create some "fill-in-the-blanks" reports from this data, ideally by taking an RTF or plaintext file as a template and replacing placeholder tags with my data.
I'd go for Cheetah: http://www.cheetahtemplate.org/
Sybren
--
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lothar |
last post by:
re:
4.2.1 Regular Expression Syntax
http://docs.python.org/lib/re-syntax.html
*?, +?, ??
Adding "?" after the qualifier makes it perform the match in non-greedy or
minimal fashion; as few...
|
by: klaus triendl |
last post by:
hi,
recently i discovered a memory leak in our code; after some investigation i
could reduce it to the following problem:
return objects of functions are handled as temporary objects, hence...
|
by: Mario |
last post by:
Hello,
I couldn't find a solution to the following problem (tried
google and dejanews), maybe I'm using the wrong keywords?
Is there a way to open a file (a linux fifo pipe actually) in...
|
by: Yves Glodt |
last post by:
Hello,
if I do this:
for row in sqlsth:
________pkcolumns.append(row.strip())
________etc
without a prior:
|
by: Adrian Herscu |
last post by:
Hi all,
In which circumstances it is appropriate to declare methods as non-virtual?
Thanx,
Adrian.
|
by: Steve - DND |
last post by:
We're currently doing some tests to determine the performance of static vs
non-static functions, and we're coming up with some odd(in our opinion)
results. We used a very simple setup. One class...
|
by: Patrick Kowalzick |
last post by:
Dear all,
I have an existing piece of code with a struct with some PODs.
struct A
{
int x;
int y;
};
|
by: ypjofficial |
last post by:
Hello All,
So far I have been reading that in case of a polymorphic class ( having
at least one virtual function in it), the virtual function call get
resolved at run time and during that the...
|
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= |
last post by:
PEP 1 specifies that PEP authors need to collect feedback from the
community. As the author of PEP 3131, I'd like to encourage comments
to the PEP included below, either here (comp.lang.python), or...
|
by: puzzlecracker |
last post by:
is it even possible or/and there is a better alternative to accept
input in a nonblocking manner?
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |