I am trying to get a cross platform method for making python files access the a shared module directory in a server hosted file system (Google Drive).
This thread explains how to import modules from other directories pretty well.
And this thread explains how to obtain the user file so that accessing Google Drive, Dropbox, etc. can be made to access the same directory easily, in conjuection with the first idea.
Putting both together:
from os.path import join, expanduser
user_path = expanduser('~')
path_for_pyfiles = join(user_path, 'Google Drive', 'Modules')
print path_for_pyfiles
sys.path.insert(0, path_for_pyfiles)
However, when I run this at a location with a mapped user folder 'U:'
, and the Google Drive is on 'C:'
, how do I retrieve the right user path?
For clarification, it prints:
'U:\\Google Drive\\Modules'
not
'C:Users\\User\\Google Drive\\Modules'
Summary: How do you get the user path associated with the a given drive?
I tried os.chdir('C:')
but that doesn't really affect it.