Question

say in on windows 7 using python language: os.path.expanduser('~') gets me 'E:\Users\san'

and in there is a Documents folder so i can get to it by os.join()

what is it called on MAC OSx or other linux distros?

Was it helpful?

Solution 2

The users directory in UNIX (Mac OS X) and UNIX-like (Linux, et al.) systems is called "Users". In that directory are the account directories. Typically in OS X, you see the one account directory for the owner of the computer, and another called "Shared". The Shared account is read-write access for everyone.

os.path.normpath(os.path.join(os.path.expanduser("~"), "Documents"))

The Documents directory for the logged in user is in the user account directory. For OS 10.4.11 or earlier, there is no default Documents directory. Some installations (MS Office, for example) create a Documents directory in older OS versions. Using UNIX pathway marks for a user called Bob Smith... /Users/bobsmith/Documents

OTHER TIPS

I think it should be mostly the same. The structure in Unix is similiar, therefore

os.path.join(os.path.expanduser("~"), "Documents")

should take you to the folder. If ~ does not work try HOME or $HOME.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top