I thought I would share this little gem of a problem I had regarding setting path variables in VuePython to ensure you can accurately locate files and directories programmatically. The basic problem is that when you start a Vue Python script fron the Vue Python shortcuts menu it will start the script from wherever the last current working directory was set. So for example, if you loaded a scene file and then executed a Python script by selecting its name from the shorcuts list, the script would execute thinking that the current path is the Vue Scenes folder. So if your Python script wanted to load a web page or load a file from some location based on a relative path, you would either have to give it an explict full pathname (not a good idea for cross platform usage) or find a reliable relative starting point from which you could find your files. I found a solution by using the later method:
# get the Vue python path
VuePythonPath = sys.path[1]
# get the Vue Python Folder
VuePythonFolder,junk = os.path.split(VuePythonPath)
# Get the Vue Root Path
VueRootPath,junk = os.path.split(VuePythonFolder)
From the Vue Root Path, I can find anything I need programmatically (e.g. scripts, scenes, objects, materials, etc)
One other thing to keep in mind. The PC and Mac use different directory and file seperators. The PC uses backslashes (\) while the Mac uses forward slashes (/). So if you are going to join a path, use Python's:
os.path.join (VueRootPath,"Materials/Basic.mtl")
The PC accepts forward and backward slashes. As an added measure of saftey, you could use:
os.path.abspath(os.path.join(VueRootPath,"Materials/Basic.mtl"))
which returns an absolute path using the slash convention of the operating system platform