Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Why does pathlib not have is_readable() & things like that? Date: Fri, 29 Apr 2016 23:53:03 +0000 (UTC) Lines: 26 Message-ID: References: <6474vcx0q6.ln2@news.ducksburg.com> <1461679044.2467938.590028273.4DEA02AA@webmail.messagingengine.com> X-Trace: news.uni-berlin.de nUeBAgGcsMtw7gHUqILEBwycMcXzrz96ixP3MNezlHgg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'works.': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'security.': 0.09; 'skip:o 60': 0.09; 'subject:Why': 0.09; 'subject:not': 0.11; '2016': 0.16; 'adam': 0.16; 'read-only.': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'windows': 0.20; 'proposed': 0.20; 'simpler': 0.22; 'am,': 0.23; 'patch': 0.24; 'header:User- Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'error': 0.27; 'fri,': 0.27; 'received:24': 0.28; 'subject:that': 0.29; "i'm": 0.30; 'checks': 0.30; 'probably': 0.31; 'received:comcast.net': 0.33; 'subject:like': 0.33; 'open': 0.33; 'file': 0.34; "isn't": 0.35; 'but': 0.36; 'there': 0.36; 'mode': 0.36; 'to:addr:python- list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'doing': 0.38; 'why': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.40; 'subject:have': 0.80; 'low': 0.83; 'edwards': 0.91 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: c-24-118-110-103.hsd1.mn.comcast.net User-Agent: slrn/1.0.2 (Linux) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <6474vcx0q6.ln2@news.ducksburg.com> <1461679044.2467938.590028273.4DEA02AA@webmail.messagingengine.com> Xref: csiph.com comp.lang.python:107872 On 2016-04-29, eryk sun wrote: > On Fri, Apr 29, 2016 at 6:51 AM, Jussi Piitulainen > wrote: >> Adam Funk writes: >>> On 2016-04-28, Grant Edwards wrote: >> >>>> Or just do os.access("directory/where/you/want/to/open/a/file",os.W_OK) >>> >>> That's what I'm doing now, but I prefer to give the user the error >>> message early on. >> >> Then do that early on. > > Note that on Windows os.access only checks if a file is read-only. > There's a proposed update to check the file security. The patch needs > to be updated and needs to be reworked, but it's a low priority. For > the most part calling os.access isn't recommended. I'm sure there are probably other ways that it fails also. That's why it's almost always simpler and better to just open the file in write mode and see if it works. -- Grant