[Tutor] string replacements using dictionaries

dman dsh8290@rit.edu
Fri, 21 Dec 2001 13:16:45 -0500


On Fri, Dec 21, 2001 at 11:56:45AM -0600, Victor R. Cardona wrote:
| Hi everyone,
| 
| I am having a bit of a problem with string replacements. I am writing a
| cgi script that reads in a html file and subtitutes all of the '%(key)s'
| markers for the values in a dictionary. There are five such markers
| containing four different keys. The dictionary has values assigned for
| the four keys. However, when I run the script I get "TypeError: Not
| enough arguements for format string" Does anyone have any idea as to
| what I am doing wrong?

Not without seeing the code.  This works fine for me :

(on one line)
>>> print "%(foo)s %(bar)s %(spam)s %(eggs)s" %
        { "foo":1 , "bar":2, "eggs":4, "spam":3 }
1 2 3 4
>>>

-D

-- 

"He is no fool who gives up what he cannot keep to gain what he cannot lose."
        --Jim Elliot