Check if a symlink is broken or circular

Giampaolo Rodola' gnewsg at gmail.com
Fri Nov 30 17:48:58 EST 2007


Hi there,
I would like to know if such function would be correct for verifying
if a link is broken and/or circular.

def isvalidlink(path):
    assert os.path.islink(path)
    try:
        os.stat(path)
    except os.error:
        return 1
    return 0



More information about the Python-list mailing list