[CentralOH] Python % Formatting

Mark Erbaugh mark at microenh.com
Fri Dec 7 17:08:25 CET 2007

Thanks for the suggestions. I agree with Catharine that there is more
than one way to do things, but I don't see anything wrong with that (at
least in Python).

As far as stripping the whitespace after the formatting, the problem is
that sometimes the characters to be stripped aren't whitespace (i.e.
commas) and sometimes the data may contain whitespace. You don't want to
convert 'New York' to 'NewYork'.

Join is a good idea, but require coding. I am looking for kind of a meta
language definition.  I like the dict/mapping capability of the %
formatting. This makes it possible to feed data directly from a database
to a print formatter. It opens the possibility of letting the user (who
doesn't want to write Python code) define the output.

Templating libraries are a good idea, but seems like it might be
overkill for this situation.

I worked up a solution, but last night after I thought it was finished
it failed a new unit test case (yes, I like to do TDD), so I've got a
little (hopefully) re-work.  When I get it done, I'll post it here.


More information about the CentralOH mailing list