Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20977

Re: check if directory is writable in a portable way

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python.list@tim.thechases.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'permissions': 0.04; 'hurts': 0.09; 'win32': 0.12; 'library': 0.13; '"don\'t': 0.16; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:50': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'things?': 0.16; 'cc:addr:python-list': 0.16; 'wrote:': 0.18; '>>>': 0.18; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; '(or': 0.22; '(though': 0.23; 'cc:2**0': 0.26; 'there.': 0.27; 'cc:addr:python.org': 0.29; 'granted,': 0.30; 'usually': 0.31; 'actually': 0.31; 'experiences': 0.32; "isn't": 0.33; 'there': 0.33; 'header:User-Agent:1': 0.33; 'running': 0.34; 'be.': 0.35; 'instead,': 0.37; 'but': 0.37; 'could': 0.38; 'should': 0.38; 'open': 0.38; 'files': 0.39; 'change': 0.40; 'chance': 0.62; 'yourself': 0.69; 'andrea': 0.84; 'slim': 0.84; 'abstracts': 0.91
Date Tue, 28 Feb 2012 06:12:44 -0600
From Tim Chase <python.list@tim.thechases.com>
User-Agent Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16
MIME-Version 1.0
To Andrea Crotti <andrea.crotti.0@gmail.com>
Subject Re: check if directory is writable in a portable way
References <4F4CA76B.5040408@gmail.com> <4F4CBBE3.5060108@tim.thechases.com> <4F4CC1FC.40502@gmail.com>
In-Reply-To <4F4CC1FC.40502@gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - boston.accountservergroup.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - tim.thechases.com
X-Source
X-Source-Args
X-Source-Dir
Cc python-list <python-list@python.org>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.224.1330431141.3037.python-list@python.org> (permalink)
Lines 22
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1330431141 news.xs4all.nl 6874 [2001:888:2000:d::a6]:56292
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:20977

Show key headers only | View raw


On 02/28/12 06:01, Andrea Crotti wrote:
>>> How should I check if I can create files in a directory?
>
> But isn't there (or should there be) a windows-related library that
> abstracts this horrible things?

Yes, there should be. There isn't as far as I know (though that 
doesn't mean much given my limited experiences in the recesses of 
Win32 APIs).

Additionally, even if you did a LBYL instead, you'd open yourself 
to a race-condition where the permissions could theoretically 
change between the time you check and the time you actually try 
to write there.  Granted, that's a slim chance and usually would 
be a "Doctor, my foot hurts when I do $THIS"/"Well don't do that" 
situation where the solution is "don't change the permissions 
while running this program".

-tkc


Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: check if directory is writable in a portable way Tim Chase <python.list@tim.thechases.com> - 2012-02-28 06:12 -0600

csiph-web