Rawest raw string literals
rosuav at gmail.com
Thu Apr 20 12:06:27 EDT 2017
On Fri, Apr 21, 2017 at 2:03 AM, Mikhail V <mikhailwas at gmail.com> wrote:
> On 20 April 2017 at 17:55, Chris Angelico <rosuav at gmail.com> wrote:
>> On Fri, Apr 21, 2017 at 1:44 AM, Mikhail V <mikhailwas at gmail.com> wrote:
>>> 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.
>> What would be the argument passed to this function?
> Yeah that is right, I cant imagine how this would work.
> But I think you get the idea- I'd want something dedicated
> to input raw strings with cute syntax and *no* escaping
> at all.
Yep. It can't be a function; it has to be a piece of language syntax.
So then the question is: what language syntax is appropriate? And
honestly, I hardly ever need this kind of thing - partly because I
wouldn't call ffmpeg this way. I'd do it like this:
cmd = ["ffmpeg", "-i", r"\\server-01\D\SER_Bigl.mpg"]
with the separate arguments as, well, separate arguments. Far less
need for double escaping that way, and you can use different escaping
rules for different arguments if you need to. (Actually, I usually use
forward slashes, so even raw string lits are unnecessary.)
More information about the Python-list