"%(a)s ... %(b)s" % {'a': foo, 'b': '%(b)s'}

Gerrit Holl gerrit.holl at pobox.com
Sat Dec 4 10:18:14 EST 1999


Hello,

I'm facing the following problem. I set __version__ and now I set a string
like this:

MAIL = '''From: someone <%(email)s>
Subject: test

this is feedback.py %(version)
''' % {'version': __version__}

This raises a KeyError. I have to type:
... % {'version': __version__, 'email': '%(email)s'}

This is ugly! Isn't there a better way to fill in just SOME of the %(...)s
values in a string and leave the rest as is?

regards,
Gerrit.

-- 
"The move was on to 'Free the Lizard'"

  -- Jim Hamerly and Tom Paquin (Open Sources, 1999 O'Reilly and Associates)
  4:16pm  up  4:36, 16 users,  load average: 1.48, 1.05, 0.91




More information about the Python-list mailing list