Skip to content

Instantly share code, notes, and snippets.

@gromgull
Created January 12, 2016 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gromgull/08bf58ceceef89d464ed to your computer and use it in GitHub Desktop.
Save gromgull/08bf58ceceef89d464ed to your computer and use it in GitHub Desktop.
from rdflib import Graph, Literal, URIRef
from rdflib.collection import Collection
g = Graph()
g.parse(data = '''<urn:thing> <urn:prop> ( 1 2 3 ) . ''', format="turtle")
collection_resource = g.value(URIRef('urn:thing'), URIRef('urn:prop'))
collection = Collection(g, collection_resource)
print list(collection)
collection.append(Literal(4))
print g.serialize(format='turtle')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment