Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (16.4k points)
edited by
They both (os.sep & os.path.sep) are the same, But which one we should use?

1 Answer

0 votes
by (26.4k points)

I recommend to use os.path.sep, since it's the path separator, it will make it very clear. But here, consistency plays an important role. In case, if you are started using one, use that. Otherwise, just pick other one and use it all the time

>>> os.path.join("foo", "bar", "baz")

'foo/bar/baz'

>>> os.path.split(_)

('foo/bar', 'baz')

Click on this link, to learn more about Miscellaneous operating system interfaces.

To know more details about Python, Come & Join: Python course

Browse Categories

...