Partial string formatting?

Gonçalo Rodrigues op73418 at
Tue Jan 21 17:18:55 CET 2003


Is there a simple way to do partial string formatting short of using
RE's, e.g

<string> % <mapping>

where if a key is not present in <mapping> it just leaves it untouched?

I thought of subclassing dict to hand out a default item, which it would
just be the requested key wrapped in %()s. Of course this only works if
the format code is s but not with other format codes or even more
complicated options.

Thanks in advance,
G. Rodrigues

More information about the Python-list mailing list