Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 4
    Yes using os.path.join is better because it joins them with the OS-specific separator. Commented Sep 4, 2016 at 9:16
  • 1
    '/relative/path...' is not a relative path. Is that intentional? Commented Feb 13, 2018 at 12:24
  • 3
    This answer is now outdated, as the top answer has been edited to use a proper relative path in os.path.join(). What is left is the preference to use separate strings for each path element over hardcoding the path separator. Commented May 12, 2018 at 18:57
  • 1
    @MartijnPieters Yes, the top answer has been edited to match this in part, but the separate strings is not a preference - separating the stings like this makes it os-independent. Commented Jul 3, 2019 at 22:39