Skip to content

Commit

Permalink
Merge pull request #334 from PuckCh/master
Browse files Browse the repository at this point in the history
Some more changes in the doc samples
  • Loading branch information
gromgull committed Oct 15, 2013
2 parents 4db34b3 + 0d7ca83 commit 38ae87f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/intro_to_creating_rdf.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ For some properties, only one value per resource makes sense (i.e they are *func

.. code-block:: python
g.add( ( bob, FOAF.age, Literal(42) )
g.add( ( bob, FOAF.age, Literal(42) ) )
print "Bob is ", g.value( bob, FOAF.age )
# prints: Bob is 42
Expand Down Expand Up @@ -124,5 +124,5 @@ for ``foaf:member_name`` (a poor man's one-way
from rdflib.namespace import FOAF
g.parse("http://danbri.livejournal.com/data/foaf")
for s,_,n: in g.triples((None, FOAF['member_name'], None)):
g.add((s, FOAF['name'], n))
for s,_,n in g.triples((None, FOAF['member_name'], None)):
g.add((s, FOAF['name'], n))
4 changes: 2 additions & 2 deletions docs/intro_to_graphs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ This function is a generator of triples that match the pattern given by the argu

g.load("some_foaf.rdf")
for s,p,o in g.triples( (None, RDF.type, FOAF.Person) ):
print "%s is a person"%o
print "%s is a person"%s

for s,p,o in g.triples( (None, RDF.type, None) ):
print "%s is a %s"%(s,o)
Expand All @@ -73,7 +73,7 @@ This function is a generator of triples that match the pattern given by the argu

If you are not interested in whole triples, you can get only the bits you want with the methods :meth:`~rdflib.graph.Graph.objects`, :meth:`~rdflib.graph.Graph.subjects`, :meth:`~rdflib.graph.Graph.predicates`, :meth:`~rdflib.graph.Graph.predicates_objects`, etc. Each take parameters for the components of the triple to constraint::

for person in g.subject(RDF.type, FOAF.Person):
for person in g.subjects(RDF.type, FOAF.Person):
print "%s is a person"%person


Expand Down
4 changes: 2 additions & 2 deletions docs/intro_to_sparql.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ Continuing the example...
import rdflib
g = rdflib.Graph()
g = rdflib.Graph()
# ... add some triples to g somehow ...
# ... add some triples to g somehow ...
g.parse("some_foaf_file.rdf")
qres = g.query(
Expand Down

0 comments on commit 38ae87f

Please sign in to comment.