def getUserDocumentsPath():
 if sys.platform.startswith('win'):
  if sys.platform.startswith('win32'):
   try:
    from win32com.shell import shell
    alt = False
   except ImportError:
    try:
     import ctypes
     dll = ctypes.windll.shell32
     alt = True
    except:
     raise Exception("Could not find 'My Documents'")
  else:
   alt = True
  if (not alt):
   df = shell.SHGetDesktopFolder()
   pidl = df.ParseDisplayName(0, None, '::{450d8fba-ad25-11d0-98a8-0800361b1103}')[1]
   path = shell.SHGetPathFromIDList(pidl)
  else:
   buf = ctypes.create_string_buffer(300)
   dll.SHGetSpecialFolderPathA(None, buf, 5, False)
   path = buf.value
 elif sys.platform.startswith('darwin'):
  from Carbon import Folder, Folders
  folderref = Folder.FSFindFolder(Folders.kUserDomain, Folders.kDocumentsFolderType, False)
  path = folderref.as_pathname()
 else:
  path = os.getenv('HOME')
 return path

def getUserDocumentsPath ( ) : if sys . platform . startswith ( 'win' ) : if sys . platform . startswith ( 'win32' ) : try : from win32com . shell import shell alt = False except ImportError : try : import ctypes dll = ctypes . windll . shell32 alt = True except : raise Exception ( "Could not find 'My Documents'" ) else : alt = True if ( not alt ) : df = shell . SHGetDesktopFolder ( ) pidl = df . ParseDisplayName ( 0 , None , '::{450d8fba-ad25-11d0-98a8-0800361b1103}' ) [ 1 ] path = shell . SHGetPathFromIDList ( pidl ) else : buf = ctypes . create_string_buffer ( 300 ) dll . SHGetSpecialFolderPathA ( None , buf , 5 , False ) path = buf . value elif sys . platform . startswith ( 'darwin' ) : from Carbon import Folder , Folders folderref = Folder . FSFindFolder ( Folders . kUserDomain , Folders . kDocumentsFolderType , False ) path = folderref . as_pathname ( ) else : path = os . getenv ( 'HOME' ) return path
find the users "documents" directory .