summaryrefslogtreecommitdiff
path: root/examples/simple_example.py
diff options
context:
space:
mode:
authorGunnar Aastrand Grimnes <gromgull@gmail.com>2013-05-02 11:23:19 +0200
committerGunnar Aastrand Grimnes <gromgull@gmail.com>2013-05-02 11:23:19 +0200
commitbdbc2a580dd1c6064b665d6bbbc3bfff6f02c783 (patch)
treea071cfabe4a9ef3ff120f742c3bcf3f96817e510 /examples/simple_example.py
parent557b1012bed875434001ca02be232159cd3b9d21 (diff)
downloadrdflib-bdbc2a580dd1c6064b665d6bbbc3bfff6f02c783.tar.gz
examples updates, some slice fixes
Diffstat (limited to 'examples/simple_example.py')
-rw-r--r--examples/simple_example.py20
1 files changed, 9 insertions, 11 deletions
diff --git a/examples/simple_example.py b/examples/simple_example.py
index 1e6c0f67..bdfb96e2 100644
--- a/examples/simple_example.py
+++ b/examples/simple_example.py
@@ -1,30 +1,28 @@
import logging
-# Configure how we want rdflib logger to log messages
+# Optional: Configure how we want rdflib logger to log messages
_logger = logging.getLogger("rdflib")
_logger.setLevel(logging.DEBUG)
_hdlr = logging.StreamHandler()
_hdlr.setFormatter(logging.Formatter('%(name)s %(levelname)s: %(message)s'))
_logger.addHandler(_hdlr)
-from rdflib import Graph, URIRef, Literal, BNode, Namespace, RDF
+from rdflib import Graph, Literal, BNode, RDF
+from rdflib.namespace import FOAF, DC
store = Graph()
-# Bind a few prefix, namespace pairs.
-store.bind("dc", "http://http://purl.org/dc/elements/1.1/")
-store.bind("foaf", "http://xmlns.com/foaf/0.1/")
-
-# Create a namespace object for the Friend of a friend namespace.
-FOAF = Namespace("http://xmlns.com/foaf/0.1/")
+# Bind a few prefix, namespace pairs for pretty output
+store.bind("dc", DC)
+store.bind("foaf", FOAF)
# Create an identifier to use as the subject for Donna.
donna = BNode()
# Add triples using store's add method.
-store.add((donna, RDF.type, FOAF["Person"]))
-store.add((donna, FOAF["nick"], Literal("donna", lang="foo")))
-store.add((donna, FOAF["name"], Literal("Donna Fales")))
+store.add((donna, RDF.type, FOAF.Person))
+store.add((donna, FOAF.nick, Literal("donna", lang="foo")))
+store.add((donna, FOAF.name, Literal("Donna Fales")))
# Iterate over triples in store and print them out.
print "--- printing raw triples ---"