Python Forum

Full Version: Path.relative_to() and symlinks
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
when a .relative_to() method is invoked for a Path() of a symlink, it follows the symlink and works on the object that symlink points to. but i want to detect if the symlink itself is relative to the object passed in the arg. my use case: a script (named "junk") to junk [verb] files being invoked by another script in which it might pass objects that are (already) in the "~/junk" directory. in the case of a symlink already there, it fails to detect that because that symlink points to somewhere outside the "~/junk" directory. how can i detect this based on where the symlink is?