Take a look at the docs for os.path.expanduser:
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:
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