ValueError: unsupported format character ‘{‘ (0x7b) in defining dictionary

I’m writing some code for web development using Google Python Appengine. In my code I have to concatenate strings using % and dictionary Here’s the code I’ve written.

def print_form(self, unameError='', passwdError='', verpasswdError='', emailError='', unameValue='', emailValue='' ):
    self.response.out.write( form3 % {  "unameError"    : unameError, 
                                        "passwdError"   : passwdError, 
                                        "verpasswdError": verpasswdError, 
                                        "emailError"    : emailError, 
                                        "unameValue"    : unameValue,  
                                        "emailValue"    : emailValue

For this code, I’m receiving this error from server :

web-app-local-directory-path/”, line 139, in print_form
“emailValue” : emailValue ValueError: unsupported format character ‘{‘ (0x7b) at index 218

I can’t seem to figure out what is wrong in this code. I’ve defined a valid dictionary and there seem to be no problem with it according to me.

Somebody please help me on this.

Vaid, Abhishek

Best answer

It sounds like you may have the sequence “%{” in the value of form3.