gjhiggins/rdflib — Issue #187: toPython() for URIRef and BNode
Author: gjhiggins
Created: 2011-10-19 01:37:12+00:00
State: open

Originally filed by bernhard...@gmail.com on 2011-09-11T09:48:45

It is quite common for us to take property values from an RDF graph and do further things with them in native python data structures. I wonder why there is no toPython() method for URIRef and BNode objects -- it would be very convenient if we could just call toPython() and do not care what the underlying RDF node actually is. Currently we have to check if it's actually a Literal before calling toPython().

For URIRef the implementation is straightforward -- it should return the reference itself:

def toPython():
return unicode(self)

Not sure about BNode, though.