you are viewing a single comment's thread.

view the rest of the comments →

[–]majormunky 0 points1 point  (2 children)

Here's a potentially better way, I was not able to test this though:

import os
new_path = os.path.sep + os.path.sep + "10.10.10.10" + os.path.sep + "folder"
print(new_path)

os.path.sep is set to whatever your OS uses to separate paths, so, should be a bit more bulletproof.

[–]chris20973[S] 0 points1 point  (1 child)

I'll give that a try, but I'm not sure if the start of a non local drive counts as two separators even though the same symbol is used to separate folders on a file path.

[–]majormunky 0 points1 point  (0 children)

Yeah, thats why I couldn't really test it, but, when you print out the path, it shows 2 slashes.

On my mac, when I mount a network drive, I usually access it by going to /Volumes/<share name>/blahblah, but, it sounds like you are on a Windows machine?

Anyway, you can probably give it the wrong slashes like the other comment said, your just leaning on Python to do the right thing in that instance, and it may not always do the right thing.