Long-time veteran of C# and Swift, but new to Python so forgive me if this is a basic question.
I'm trying to solve a seemingly simple problem. We have a Python3 function that takes a list of directories represented as a string array. We're using those values in some outputted JSON and in that JSON, it has to have a guaranteed format.
What we're trying to address is the following case (Note: This will either be on macOS or Linux):
File 1: /Users/Joe/Some/Path/To/Folder/
File 2: /Users/Joe/Some/Path/To/Folder <-- Note the missing trailing slash
File 3: ~/Some/Path/To/Folder/ <-- Note the 'home' tilde
All three of the above should output a format matching File 1 above...
/Users/Joe/Some/Path/To/Folder/
Well I can do this with regex and/or string manipulation, I’m hoping there’s something in a standard library‘s that I can use, especially to get platform-independence where on some systems things are forward-slashes and others they are back-slashes.
Any ideas?