Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.010 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:getting': 0.07; '"my': 0.09; 'indicates': 0.09; 'received:internal': 0.09; 'hresult': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'osx': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:10.202.2.212': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:messagingengine.com': 0.16; 'subject:windows': 0.16; 'versions': 0.20; 'windows': 0.20; 'ctypes': 0.22; 'import': 0.24; 'header:In-Reply-To:1': 0.24; 'example': 0.26; 'linux': 0.26; '(e.g.': 0.27; 'correct': 0.28; 'raise': 0.29; "i'm": 0.30; 'print': 0.30; 'folder': 0.30; 'skip:[ 10': 0.31; 'generally': 0.32; 'language.': 0.32; 'older': 0.32; 'skip:c 30': 0.35; 'path': 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'really': 0.37; 'mac': 0.37; 'received:66': 0.38; 'test': 0.39; 'skip:x 10': 0.40; 'to:addr:python.org': 0.40; 'from:no real name:2**0': 0.60; 'header:Message-Id:1': 0.61; 'provide': 0.61; 'documents': 0.61; 'guaranteed': 0.67; 'foreign': 0.69; 'now)': 0.84 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.us; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=ZsnciowtT1OGM/ATyNGdbKuSbLA=; b=LSZVz2 TLNVuuT46ekqfTq7u/D4GT66HAhrDzvvyN2mkdoXxnzMqe12SdaBhig1BPbxST5O ZcTTVcU4bfmxBswZ9DgJGkYPe8AZCpM7TA0xOnlHQ2o866ks7sfAaVOK/3VmJsQ4 rC2VtMmCwUwAAYUeWGOEZS6pWXLXI7O87JXv0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=ZsnciowtT1OGM/A TyNGdbKuSbLA=; b=ig8OhVd3EEDLT+ZZMtXD/lKBArnwlkLlHXLEaiCoiiEALOk 9jZe+9qzUAziG/LJEhJ9ilWLyy3rrLDy8Mf03vRrcpXT6F7/3gfi7YGXtLBXaQ/e KzQNYvCat/eNw3ZQkyEyVaaHHCRNXFoA15atMTWWPJA/F2VHcnkYR9Avpz0c= X-Sasl-Enc: r0mCUBZZnW9EEWghdRzrNgGepauILIcy0qtw92ubpyZF 1436574244 From: random832@fastmail.us To: python-list@python.org MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain X-Mailer: MessagingEngine.com Webmail Interface - ajax-bfc056ae In-Reply-To: <20150710094607.66e62712@bigbox.christie.dr> References: <20150710094607.66e62712@bigbox.christie.dr> Subject: Re: Trouble getting to windows My Documents directory Date: Fri, 10 Jul 2015 20:24:04 -0400 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1436574781 news.xs4all.nl 2856 [2001:888:2000:d::a6]:57961 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93660 The My Documents directory is not guaranteed to be named "Documents". On older versions of windows it was "My Documents", and on foreign versions of windows it is a name in their language. The correct way to get the path of this folder is, for example (couldn't test since I'm on a mac right now) import ctypes from ctypes import wintypes CSIDL_PERSONAL = 5 SHGetFolderPath = ctypes.windll.shell32.SHGetFolderPathW pszPath = ctypes.create_unicode_buffer(wintypes.MAX_PATH) SHGetFolderPath.argtypes = [wintypes.HWND, ctypes.c_int, wintypes.HANDLE, wintypes.DWORD, LPWSTR] SHGetFolderPath.restype = wintypes.HRESULT hResult = SHGetFolderPath(0, CSIDL_PERSONAL, 0, 0, pszPath) if hResult == 0: print pszPath.value else raise OSError("Could not find My Documents directory") Linux systems generally provide their own way to get it (e.g. xdg-user-dirs), on OSX everything I can find indicates it really is always ~/Documents .