Every single script I have written that involves pathing to the local file system always ends up broken at some point. This is because behind the scenes Blender or Python mangles my valid string intentions for paths into some kind of gobbly gook that is not recognized as a path any more.
For instance, this morning on my Window machine I type:
import os COMPILER_PATH = "C:\Program Files\3Delight\bin" if os.path.exists(COMPILER_PATH): print ("valid path on Windows") else: print ("invalid path on Windows")
COMPILER_PATH is the string that was returned to me by Blender when I browsed to using a FILE_PATH type GUI input field. Python, of course, sees this as invalid. See image, I now have a ‘heart’ icon as part of my string path (WTF).
I am tired of constantly writing path fixup code for various cases and OS’s. I would like a solution for pathing that works for every OS all the time and never breaks.
Can someone show me the correct way to process files and folder paths so it works for all OS’s and can be used with the subprocess command? I want to launch other executables with parameters.