> Thanks, > I am aware of goodies that raw string offers, but my question was > how to use it with variable that already contains string. :)
If you really have to, you may use something like this: # Untested def kludge(s): s = 'r"""%s"""' % repr(s) return eval(s) Most people would frown at the use of eval (in fact I do too), because it is possible to leak dangerous code from this function, given certain string sequences. But, that's enough of a kludge and don't ask for more kludges. THE correct way to fix the problem is not here, but in the input function (the function that assigns the variable)... If you're reading from a file, and you get this problem, most probably the program that generates the file is the problem. Check the file's real content... If you're reading from standard input, make sure you use raw_input(), instead of input(), as text in input() is eval()ed first, not something we would want... _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor