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 is, in what types of circumstances would it be
>both appropriate and safe to use?
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
think that is the thing to call)
Open does more that os.stat (which is what os.path.exists uses underneath).
There are plenty of times you will want to know a file exists but not have
permission to open it. Also, open can have side effects if the target file is a
device or a socket/pipe.
Always use the smallest thing you can to achieve an effect: stat is smaller
than open.
Cheers,
Cameron Simpson <c...@zip.com.au>
Q: How many user support people does it take to change a light bulb?
A: We have an exact copy of the light bulb here and it seems to be
working fine. Can you tell me what kind of system you have?
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor