Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: eryk sun Newsgroups: comp.lang.python Subject: Re: Why does pathlib not have is_readable() & things like that? Date: Fri, 29 Apr 2016 10:09:41 -0500 Lines: 16 Message-ID: References: <6474vcx0q6.ln2@news.ducksburg.com> <1461679044.2467938.590028273.4DEA02AA@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de IV++Tt3pjwIkWw5WMT4EbwGWJqpG3HQIqXrQIvK1TH4A== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'received:209.85.223': 0.03; '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:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; '>>>': 0.20; 'windows': 0.20; 'proposed': 0.20; 'am,': 0.23; 'patch': 0.24; 'header:In-Reply-To:1': 0.24; 'error': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'subject:that': 0.29; "i'm": 0.30; 'checks': 0.30; 'subject:like': 0.33; 'file': 0.34; 'received:google.com': 0.35; "isn't": 0.35; 'but': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'doing': 0.38; 'received:209': 0.38; 'to:addr:python.org': 0.40; 'subject:have': 0.80; 'low': 0.83; 'edwards': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=+KTo7+nBXHijw6XhNXkMhI+j+dzAQPHJqoG5tPPE+TM=; b=rg1K/BwSpH3DkRSbeZDRWTQE6a3hz0dkI/qZccI9+8S8uZ1SOSnFoWLokJJBelFY06 gkf3onxZSFwEqzglwTkIcIaQEUVrYYHSGvuGoYIMnceB2Y6LP2eUUgfIQSHyvwN7BndT Ux7jBCObjnxfEQ/zGHoW9D0mSaV/6CKI3WxobatmgtIHDMsBgvNdmITtUkfUWybTGzGB tAQDlOqGW231C1s0l49UPayFvdsdqvgZhzPs6xHcS+XI1DnuGoanVbkkHjUVV+aiv3hl j8LiNRYh6PMXVPHV0szTnq6nXjK7HCYfhMNYVJw5wzFni8wYD3d+MgAngyHSa6uzAh4b mljQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=+KTo7+nBXHijw6XhNXkMhI+j+dzAQPHJqoG5tPPE+TM=; b=DsiZKcWOZkkBBs9Fyz6N1bP+zmLAv+Lr5i5N8Xr3i/9hf+NawWWNwDgy+5D4rOsNFI 9JSjCYjq2hW/Vt9HDBB4mE31i4FOiVWRgnpVDDPUgKKSOxnI+GjjwIRfThjUkLyPWoRG TvL2H1Uhge+SBbLEPNejj0r0J+KzX2Qm3+LQliTyItCE8wrgqL+Fv4qYdFQvrdECTIJs GodzBM9kpPEQANQlrx2poFknHtKLKD1HYpbPRfVWfljSvCtPi2rNGzt3wCuKUCL8kuGo vZL3UZxivjAJtZ8CgscvPXd/hrvIBGOQoh+vvE35PRg4GEJTcmA2iWcAdZdaIx8UewVD 0uLQ== X-Gm-Message-State: AOPr4FVW9blvoajEK+rVKZC3dk4K+wxX9W6nw7mUt+rMahLsf1hOsExqKxQePakI5uro1CtVqQbJxHI9jZmVSQ== X-Received: by 10.107.55.138 with SMTP id e132mr20245425ioa.188.1461942621335; Fri, 29 Apr 2016 08:10:21 -0700 (PDT) In-Reply-To: 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:107858 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.