Return a file’s ancestors.


file.parents() Collection file.parents(cross bool) Collection


cross bool (default false)

Cross filesystem boundaries. Getting the parents from within an imported filesystem returns parents up to the imported root. With crossing enabled, all parents will be returned up to the highest file in the chain. With crossing enabled, you will always get what you would expect by path.


Return a collection of a file’s ancestors in hierarchical order (deepest last).


Basic example.

When no parent exists an empty collection is returned.

Cross filesystem boundaries. Note that in this playground, we can not import remote filesystems, thus we can not show the difference here of using the cross argument.