escaping

Steve Howell showell30 at yahoo.com
Sun Apr 15 17:13:14 EDT 2012


On Apr 15, 2:07 pm, Kiuhnm <kiuhnm03.4t.yahoo.it> wrote:
> This is the behavior I need:
>      path = path.replace('\\', '\\\\')
>      msg = ". {} .. '{}' .. {} .".format(a, path, b)
> Is there a better way?
>

A little more context would help.  The quadruple-toothpick idiom
predates Python.  It's a little hard on the fingers and eyes at first,
but it's pretty expressive--most people will clearly see that you are
dealing with escaping issues.

If you are just printing a message to the log, consider repr().



More information about the Python-list mailing list