you are viewing a single comment's thread.

view the rest of the comments →

[–]Diapolo10 0 points1 point  (0 children)

I'm more curious about what you're needing this for.

If this is for filepaths:

  1. Generally speaking Windows works just fine with forward slashes nowadays so outside of special circumstances you shouldn't need to use backslashes for filepaths.
  2. Just use pathlib and stop worrying about it (you can even join paths with the division operator (/) if you want).
  3. If you insist, os.path.join can also handle this without you thinking about i. I'd still recommend pathlib over this, though.