How do you get the exact path to "My Documents"?
python, windows
Solution
You could use the ctypes module to get the "My Documents" directory:
import ctypes
from ctypes.wintypes import MAX_PATH
dll = ctypes.windll.shell32
buf = ctypes.create_unicode_buffer(MAX_PATH + 1)
if dll.SHGetSpecialFolderPathW(None, buf, 0x0005, False):
print(buf.value)
else:
print("Failure!")
Source: http://bugs.python.org/issue1763#msg62242
Problem
In C++ it's not too hard to get the full pathname to the folder that the shell calls "My Documents" in Windows XP and Windows 7 and "Documents" in Vista; see Get path to My Documents Is there a simple way to do this in Python?