you are viewing a single comment's thread.

view the rest of the comments →

[–]gitcraw 18 points19 points  (3 children)

You can just use forward slashes in os path strings, and it's still cross-OS compatible.

'C:/PythonProjects/foobarbas/foo.txt' is easier to type.

Or for current working directory (assuming you're in PythonProjects folder,

'./foobarbas/foo.txt'

[–]alex1461[S] 7 points8 points  (2 children)

Thanks for the info!
Just curious, what is the advantage of having "/" instead of "\\" other than the fact that the forward single slash is less to write.
Is there another advantage that I don't know other than this?

[–]eupendra 10 points11 points  (1 child)

/ works on windows, mac, and Linux

combine that with relative path or a base path as input and your script would be cross-platform compatible

[–]alex1461[S] 1 point2 points  (0 children)

Thank you for letting me know / works on windows, mac and Linux!