trouble using \ to escape %

Lucas Machado LMachado1 at gmail.com
Fri Apr 15 19:05:34 EDT 2005


I'm writing a python script that modifies the smb.conf file, and i need
to write the characters '%U' in the file.  I tried making a string like
so:

str1 = "[%s%s]\n\tpath = /mnt/samba/%s%s/\%U" % (list[0], list[1],
list[0], list[1])

but i keep getting: "TypeError: not enough arguments for format
string". I've also tried making the string:

str1 = "[%s%s]\n\tpath = /mnt/samba/%s%s/\%" % (list[0], list[1],
list[0], list[1])

but i get: "ValueError: incomplete format". These errors lead me to
believe that for some reason it is not escaping the '%' character.
There has to be a way to write '%' to a file. Thanks in advance..

Cheers
-Lucas Machado




More information about the Python-list mailing list