ideasman42
ideasman42

Reputation: 48128

How to quote paths on windows? (similar to shlex.quote)

I need to quote a path in a portable way, shlex.quote is converting slashes to / on windows, which causes the command to fail (using the default windows command prompt).


Returning C:/Users/Me/Documents/Projects/Test

Instead of C:\Users\Me\Documents\Projects\Test


How can I quote a path on windows, similar to shlex.quote that uses native slashes, suitable for the windows command prompt and BAT files?

Upvotes: 4

Views: 2048

Answers (1)

Adrian Friedli
Adrian Friedli

Reputation: 115

As mentioned by some comments, your problem might not be caused by shlex.quote().

Nevertheless there is the module mslex which provides mslex.quote() and mslex.split() for the Windows shell, just like what shlex provides for the Unix shell.

Upvotes: 2

Related Questions