Take a look at the docs for os.path.expanduser:
http://docs.python.org/library/os.path.html
There are a few environment variables that it will check to try and get a value
to be joined to the user name. Maya could very well be changing those. Try
printing out the values of them and seeing what they are. You may need to join
it manually using a specific env variable.
print os.getenv("HOME")
print os.getenv("USERPROFILE")
Linux has a pwd module that works regardless of env.
Apparently there is a windows specific approach as well:
http://stackoverflow.com/questions/2668909/how-to-find-the-real-user-home-directory-using-python
It just depends on if you are trying to make a cross platform compatible
script? If so, you will have to check a couple cases for the current platform,
and also not use "\\" for paths. Use "/", or just os.path.join to make sure
paths work no matter which OS
On May 17, 2012, at 10:27 PM, Panupat Chongstitwattana <[email protected]>
wrote:
> Hi.
>
> I'm storing some local files location using the following command
>
> LITEPATH = os.path.normpath(os.path.expanduser('~') + '\\dirName')
>
> In Maya I would get , C:\Users\Me\Documents\dirName
> But when running alone using python IDE, I get C:\Users\Me\dirName
>
> What could be the cause of this and how I can force it to be identical?
> --
> view archives: http://groups.google.com/group/python_inside_maya
> change your subscription settings:
> http://groups.google.com/group/python_inside_maya/subscribe
--
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings:
http://groups.google.com/group/python_inside_maya/subscribe