In a message of Sat, 15 Aug 2015 15:20:19 -0700, Clayton Kirkwood writes:
If you want to locate dangling symlinks, os.path.exists will return
False, so
the symlink is there, but the file it pointed to is long gone.
Can't you do that with os.path.open() and get a value in os.path.status? (I
On Sat, Aug 15, 2015 at 07:04:47PM -0500, boB Stepp wrote:
On Sat, Aug 15, 2015 at 6:41 PM, Steven D'Aprano st...@pearwood.info wrote:
On Sat, Aug 15, 2015 at 02:24:21PM -0500, boB Stepp wrote:
I understand your points, but wonder then what is the intended use for
os.path.exists()? That
In a message of Sat, 15 Aug 2015 14:24:21 -0500, boB Stepp writes:
I understand your points, but wonder then what is the intended use for
os.path.exists()? That is, in what types of circumstances would it be
both appropriate and safe to use?
boB
If you want to locate dangling symlinks,
On 15Aug2015 15:20, Clayton Kirkwood c...@godblessthe.us wrote:
Behalf Of Laura Creighton
[..]
To: boB Stepp robertvst...@gmail.com
In a message of Sat, 15 Aug 2015 14:24:21 -0500, boB Stepp writes:
I understand your points, but wonder then what is the intended use for
os.path.exists()? That
-Original Message-
From: Tutor [mailto:tutor-bounces+crk=godblessthe...@python.org] On
Behalf Of Laura Creighton
Sent: Saturday, August 15, 2015 2:49 PM
To: boB Stepp robertvst...@gmail.com
Cc: l...@openend.se; tutor tutor@python.org
Subject: Re: [Tutor] try and file existence
On Sat, Aug 15, 2015 at 02:24:21PM -0500, boB Stepp wrote:
On Fri, Aug 14, 2015 at 10:39 PM, Steven D'Aprano st...@pearwood.info wrote:
There is also os.path.exists(filename), but you should avoid using that
if possible. The problem is this:
if os.path.exists(filename):
# file
On Sat, Aug 15, 2015 at 6:41 PM, Steven D'Aprano st...@pearwood.info wrote:
On Sat, Aug 15, 2015 at 02:24:21PM -0500, boB Stepp wrote:
I understand your points, but wonder then what is the intended use for
os.path.exists()? That is, in what types of circumstances would it be
both appropriate
On 15/08/2015 04:39, Steven D'Aprano wrote:
On Fri, Aug 14, 2015 at 06:28:09PM -0700, Clayton Kirkwood wrote:
try:
fp = open( user_preferences )
except( PermissionError ):
else:
with open(user_preferences ) as f:
try:
fp = open(user_preferences)
except (IOError, OSError) as e:
On Fri, Aug 14, 2015 at 10:39 PM, Steven D'Aprano st...@pearwood.info wrote:
On Fri, Aug 14, 2015 at 06:28:09PM -0700, Clayton Kirkwood wrote:
what is the best way to find out if a file exists?
Try to open it and see what happens. If the open() succeeds, then the
file exists and can be
On 15/08/2015 02:28, Clayton Kirkwood wrote:
try:
fp = open( user_preferences )
except( PermissionError ):
You need a pass statement here if you don't intend doing anything with
the error, but see my comments at the bottom.
else:
with open(user_preferences ) as f:
I originally
On 14Aug2015 18:28, Clayton Kirkwood c...@godblessthe.us wrote:
try:
fp = open( user_preferences )
except( PermissionError ):
else:
with open(user_preferences ) as f:
I originally only had the bottom open statement. Ran but file didn't exist,
and my run failed with file doesn't exist. I
On Fri, Aug 14, 2015 at 06:28:09PM -0700, Clayton Kirkwood wrote:
try:
fp = open( user_preferences )
except( PermissionError ):
else:
with open(user_preferences ) as f:
try:
fp = open(user_preferences)
except (IOError, OSError) as e:
handle_error()
else:
with fp as f:
12 matches
Mail list logo