Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR contains several enhancements to the
Prolog.consult
method.Tilde character in paths are expanded to the user home directory
Both strings and pathlib.Path objects are allowed as paths
Added relative_to keyword argument
relative_to
keyword argument makes it easier to construct the consult path.This keyword is no-op, if the consult path is absolute.
If the given
relative_to
path is a file, then the consult path is updated to become a sibling of that path.Assume you have the
/home/me/project/facts.pl
that you want to consult from therun.py
file which exists in the same directory/home/me/project
.Using the built-in
__file__
constant which contains the path of the current Python file , it becomes very easy to do that:If the given
relative_path
is a directory, then the consult path is updated to become a child of that path.Symbolic links are not yet supported yet.