In Python syntax:

 # import the libraries
 from rdflib.TripleStore import TripleStore
 from rdflib.URIRef import URIRef
 # resource for a specific URI:
 subject = URIRef("URI_of_Subject")
 # create the triple store
 triples = TripleStore()
 # parse an RDF file and store it in the triple store
 triples.load("membership.rdf")
 # do something with (p,o) pairs
 for (p,o) in triples.predicate_objects(subject) :
 	  do_something(p,o)