How to change '\\' to '\'

Thomas Jollans tjol at tjol.eu
Mon Oct 1 05:28:36 EDT 2018


On 2018-10-01 11:19, Jach Fong wrote:
> Hmmm...strange, I didn't see Rick's mail:-(

That's because he's banned from the list, but still around on the newsgroup

> Sure the forward slash is better, not to cause this confusion.
> But I am curious, since when, I mean, since which version
> Windows start to accept forward slash?

Windows has always supported forward slashes in most contexts for
compatibility with UNIX software. (just not in cmd.exe IIRC)

> 
> --Jach
> 
> Alister ware via Python-list at 2018/10/1 PM 04:15 wrote:
>> On Sun, 30 Sep 2018 17:45:52 -0700, Rick Johnson wrote:
>>
>>> Jach Fong wrote:
>>>> I get a string item, for example path[0], from path =
>>>> os.get_exec_path()
>>>> It's something like "\\Borland\\Bcc55\\Include", a Python string.
>>>> I want to use this "string" in a subprocess command as a parameter.
>>>> Obviously this command can only recognize "\Borland\Bcc55\Include".
>>>> I know there must have an easy way to convert it, but just can't figure
>>>> it out :-(
>>>
>>> I would suggest substituting all backslashes with forward slashes, that
>>> way, the printed version and the internal escaped version won't be
>>> confusing to you. And besides, which is easier to read?
>>>
>>> This?
>>>
>>>    "\\Borland\\Bcc55\\Include"
>>>
>>> Or this?
>>>
>>>    "/Borland/Bcc55/Include"
>>>
>>> ???
>>>
>>> </lesson>
>>
>> Practicality Beats Purity
>>
>>
>>
>>
> 
> ---
> This email has been checked for viruses by Avast antivirus software.
> https://www.avast.com/antivirus
> 


-- 
Thomas Jollans

m ☎ +31 (6) 42630259
e ✉ tjol at tjol.eu



More information about the Python-list mailing list