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 >think that is the thing to call) >crk >> >> Laura
There is no os.path.open I assume you are thinking of os.open? or open the builtin? or maybe os.stat? If what you really want to do is open the file, if it exists, then trying to open it and then if that fails handle whatever problem you get is most often the way to go. But often you never wanted to open it in the first place. Maybe it is a directory. Maybe it is a lockfile --- oops, I will come back later. There are a lot of times when the sense you really want is not 'check if this valued file exists' but rather 'check for cruft you don't want to find'. Open is also slow, which again isn't a problem if you need to open the file anyway, but will matter if all you want to do is check your entire large filesystem for files named 'core'. Laura _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor