Rawest raw string literals

Mikhail V mikhailwas at gmail.com
Thu Apr 20 16:46:37 EDT 2017


On 20 April 2017 at 19:27, Chris Angelico <rosuav at gmail.com> wrote:
> On Fri, Apr 21, 2017 at 2:26 AM,  <breamoreboy at gmail.com> wrote:
>> I find this:-
>>
>> s = r"ffmpeg -i  '\\server-01\D\SER_Bigl.mpg' "
>>
>> vastly superior.
>
> It's semantically different though. I don't know whether single quotes
> are valid in that context, on Windows.
>

For ffmpeg on Windows at least, both single and double quotes work equally.
So yes, if I keep the rule to use single quotes only inside commands
then I'd be fine with r"".
I simply don't like single quotes, and tend to use doble quotes
everywhere for better readability.

Well it is just somewhat unfortunate, because literals use
the quotes as a open/close tag, which are very common character in
strings. So the idea was to choose something that is not so
frequent and much less probable to appear in a string.
But the less probable it is, the more complex or ugly would the tag
become.
E.g. curly braces {} seems to be much less frequent characters
for filenames and command line arguments.


Mikhail



More information about the Python-list mailing list