summaryrefslogtreecommitdiff
path: root/examples/slice.py
diff options
context:
space:
mode:
authorNicholas Car <nicholas.car@csiro.au>2020-03-27 21:19:06 +1000
committerNicholas Car <nicholas.car@csiro.au>2020-03-27 21:19:06 +1000
commitb4a4f62388c76ac7bf161e88ddf7d81a41683d82 (patch)
treee218560995af9ce69e08c78af9c237b8d46bfad3 /examples/slice.py
parent586331223f769ecc72814da4ce5fab60154de3fc (diff)
downloadrdflib-b4a4f62388c76ac7bf161e88ddf7d81a41683d82.tar.gz
touched up all examples
Diffstat (limited to 'examples/slice.py')
-rw-r--r--examples/slice.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/examples/slice.py b/examples/slice.py
index 525edb95..eaab1540 100644
--- a/examples/slice.py
+++ b/examples/slice.py
@@ -1,5 +1,4 @@
"""
-
RDFLib Graphs (and Resources) can be "sliced" with [] syntax
This is a short-hand for iterating over triples
@@ -8,21 +7,20 @@ Combined with SPARQL paths (see ``foafpaths.py``) - quite complex queries
can be realised.
See :meth:`rdflib.graph.Graph.__getitem__` for details
-
"""
from rdflib import Graph, RDF
from rdflib.namespace import FOAF
-if __name__ == '__main__':
+if __name__ == "__main__":
graph = Graph()
- graph.load("foaf.rdf")
+ graph.load("foaf.n3", format="n3")
for person in graph[: RDF.type: FOAF.Person]:
- friends = list(graph[person:FOAF.knows * '+' / FOAF.name])
+ friends = list(graph[person: FOAF.knows * "+" / FOAF.name])
if friends:
print("%s's circle of friends:" % graph.value(person, FOAF.name))
for name in friends: