Rawest raw string literals
Mikhail V
mikhailwas at gmail.com
Thu Apr 20 11:44:45 EDT 2017
Quite often I need raw string literals for concatenating console commands.
I want to input them exactly as they are in python sources.
There is r"" string, but it is obviously not enough because e.g. this:
s = r"ffmpeg -i "\\server-01\D\SER_Bigl.mpg" "
is not valid.
The closest I've found is triple quote literal:
s = r"""ffmpeg -i "\\server-01\D\SER_Bigl__" """
This is what I use now, still there is problem: last quote inside the string
needs escaping or a space character before closing triple quote,
otherwise there is again an error.
What I think: why there is no some built-in function, for example like:
s = raw("ffmpeg -i "\\server-01\D\SER_Bigl__"")
which would just need *one* quote sign in the beginning and on the end.
Would it be useful, what do you think? I think looks better than triple quote.
In the past there were quite a lot additions to string manipulation,
probably there is already something like this.
Mikhail
More information about the Python-list
mailing list