[Python-ideas] os.path.cansymlink(path)

Chris Angelico rosuav at gmail.com
Fri Jul 25 12:53:02 CEST 2014


On Fri, Jul 25, 2014 at 8:17 PM, anatoly techtonik <techtonik at gmail.com> wrote:
> You do realize that high level program logic changes depending on the fact
> that FS supports symlinks or not. It is not "an exceptional" case as you've
> presented it.

There are plenty of other non-exceptional cases that are signalled
with exceptions. It's part of the EAFP model and its reliability. If
high level logic changes, it surely can be like this:

try:
    os.symlink(whatever)
except OSError:
    alternate_logic()

How would asking the path if it's symlinkable (by the way, do you ask
the source or destination?) improve that?

ChrisA


More information about the Python-ideas mailing list