I have a list of file names produced by a third party. They all look like this: `'D:\\a\\b\\c/d/e/f/g.cpp'`.
I would like to normalize these to have a uniform path separator. However the command:

```
os.path.normpath('D:\\a\\b\\c/d/e/f/g.cpp')

```

does nothing to the string under Linux (Python3).
Under Windows I get the expected result, i.e. all slashes converted to `\\`.
How can I make it work under Linux, without resorting to regex? Is it a bug?
['https://Stackoverflow.com/questions/46545841', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2077783/']
On Windows, `os.path` redirects to `ntpath` module which is aware of `\`, drives, ...

On Linux, you have to import & use `ntpath` explicitly because you're not using the native separators.

The code below works on both platforms:

```
>>> import ntpath
>>> ntpath.normpath(r'D:\a\b\c/d/e/f/g.cpp')
'D:\\a\\b\\c\\d\\e\\f\\g.cpp'
>>> 

```

(note the usage of `r` prefix when pasting the paths, avoids doubling the backslashes)
I find this to be the best option just write your own function

```
import os
def norm_path(path_in, sep=None):
    if sep==None:
        sep = os.sep
    tmp_list = '\\'.join([k for k in path_in.split('/') if len(k)>0])
    final_list = [k for k in tmp_list.split('\\') if len(k)>0]
    return sep.join(final_list)

```

or if you don't want to use any packages then just

```
def norm_path(path_in, sep='/'):
    tmp_list = '\\'.join([k for k in path_in.split('/') if len(k)>0])
    final_list = [k for k in tmp_list.split('\\') if len(k)>0]
    return sep.join(final_list)

```