pythonredland

Redland python bindings.Unexpected print ot triples


I have the below code in python:

import RDF


parser = RDF.Parser()

model=RDF.Model()

stream=parser.parse_into_model(model,"file:./zoo/zoo.rdf")

list = []
for triple in model:
    print triple.subject, triple.predicate, triple.object
    list.append([ triple.subject , triple.predicate , triple.object ] )
print len(list)
for k in list:
  print k

at the first loop the statements of my rdf are printed correctly.But at the 2nd statement the addresses of each element is printed out:

 < RDF.Node object at 0x7eec158c>, < RDF.Node object at 0x7eec1b2c>, < RDF.Node object at 
0x7eec1b8c>


< RDF.Node object at 0x7eec146c>, < RDF.Node object at 0x7eec606c>, < RDF.Node object at 0x7eec612c>

. . .

Why this is happened instead of printing the statements?


Solution

  • Try

    for k in list:
        print map(str, k)