[Tutor] ValueError

Remco Gerlich scarblac@pino.selwerd.nl
Thu, 25 Jan 2001 09:27:28 +0100


On Thu, Jan 25, 2001 at 10:59:52AM +1000, Suzanne Little wrote:
> I'm hoping someone can suggest a potential solution for why I'm getting
> this error.
> 
> Quick background:
> It's a script that generates an html page. There's a variable (BODY) with
> a large  string of html (in ''') and %(var_name)s in various places. The
> function takes a dictionary and does some bit's and pieces before
> html_string.append(BODY % dictionary) is called. This is where the
> following error is occuring.
> <--->
> File formatter.py, line 271, in build_single
>   html_string.append(BODY % dictionary)
> ValueError: unsupported format character '"' (0x22)
> 
> I figured that I'd forgotten to escape one of my " in the BODY string but
> I'm fairly sure that I've gotten them all besides which, if I understand
> what I was just looking at in the tutorial, I can have double quotes in my
> string if it's inside single quotes and vice versa. (Is this true of
> triple quotes ''' " '''?)  The string BODY appears valid and the
> dictionary seems fine. (The words appears and seems are deliberate since
> something's got to be causing the error :))
> 
> So I'm a bit puzzled. This is the second function of this type I've
> written and the first was fine. Any ideas where I should be looking?
> The code's really too long and ugly to post so hopefully the above is
> enough for someone to give me some clues.

It's the % operator that is complaining about a " somewhere. Do you have
a combination like %" somewhere?

-- 
Remco Gerlich