diff options
author | Nicholas Car <nicholas.car@surroundaustralia.com> | 2021-06-18 20:02:29 +1000 |
---|---|---|
committer | Nicholas Car <nicholas.car@surroundaustralia.com> | 2021-06-18 20:02:29 +1000 |
commit | a4727c1494a4cc93f8d78620db558aa3c23e83e6 (patch) | |
tree | 328d9b9f27cf292557adbe8b3a8a9b3cc0f83eb7 /examples/slice.py | |
parent | 2bc50a48c1cb4f1d932ea3541dbd1aab6ee5b91b (diff) | |
download | rdflib-a4727c1494a4cc93f8d78620db558aa3c23e83e6.tar.gz |
ensure all examples work
Diffstat (limited to 'examples/slice.py')
-rw-r--r-- | examples/slice.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/examples/slice.py b/examples/slice.py index 33aacf9b..de3bb731 100644 --- a/examples/slice.py +++ b/examples/slice.py @@ -1,7 +1,7 @@ """ RDFLib Graphs (and Resources) can be "sliced" with [] syntax -This is a short-hand for iterating over triples +This is a short-hand for iterating over triples. Combined with SPARQL paths (see ``foafpaths.py``) - quite complex queries can be realised. @@ -15,13 +15,11 @@ from rdflib.namespace import FOAF if __name__ == "__main__": graph = Graph() - graph.load("foaf.n3", format="n3") - for person in graph[: RDF.type : FOAF.Person]: - - friends = list(graph[person : FOAF.knows * "+" / FOAF.name]) + for person in graph[: RDF.type: FOAF.Person]: + friends = list(graph[person: FOAF.knows * "+" / FOAF.name]) if friends: - print("%s's circle of friends:" % graph.value(person, FOAF.name)) + print(f"{graph.value(person, FOAF.name)}'s circle of friends:") for name in friends: print(name) |