repr(string)

Fredrik Lundh fredrik at pythonware.com
Wed Jul 23 16:06:18 EDT 2008


David C. Ullrich wrote:

> I've been saving data in a file with one line per field.
> Now some of the fields may become multi-line strings...
> 
> I was about to start escaping and unescaping linefeeds
> by hand, when I realized that repr() and eval() should
> do. Hence the question: If s is a string, is repr(s)
> guaranteed not to contain line breaks?

yes.

just keep in mind that using eval() on untrusted data isn't a very good 
idea.

</F>




More information about the Python-list mailing list