[Patches] [ python-Patches-1068277 ] os.path.exists returns False if no permission

SourceForge.net noreply at sourceforge.net
Mon Dec 20 15:53:03 CET 2004


Patches item #1068277, was opened at 2004-11-17 21:20
Message generated for change (Comment added) made by arigo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1068277&group_id=5470

Category: Documentation
Group: Python 2.5
Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Robert Brewer (aminusfu)
Assigned to: Nobody/Anonymous (nobody)
Summary: os.path.exists returns False if no permission

Initial Comment:
A single new sentence for os.path.exists description,
which makes it clear that it may return False even if
the path actually exists.

----------------------------------------------------------------------

>Comment By: Armin Rigo (arigo)
Date: 2004-12-20 14:53

Message:
Logged In: YES 
user_id=4771

Actually, what about the following ?

    def exists(path):
        return os.access(path, os.F_OK)

It returns True on all existing directory entries apart from broken links and links pointing within unreadable directories.

I don't see any similar nice solution for the more recent os.path.lexists()...  There are cases where the above exists() returns True but the current lexists() returns False, which is strange because lexists() is supposed to be a more permissive version of exists().

----------------------------------------------------------------------

Comment By: Armin Rigo (arigo)
Date: 2004-12-20 13:00

Message:
Logged In: YES 
user_id=4771

I don't see an obvious way to do it, but shouldn't os.path.exists() try harder to return the expected answer?

----------------------------------------------------------------------

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2004-12-05 06:56

Message:
Logged In: YES 
user_id=3066

This should be committed on the trunk and release24-maint
branch.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1068277&group_id=5470


More information about the Patches mailing list