RDFLib/rdflib — Issue #174: toPython() for URIRef and BNode
Author: gjhiggins
Created: 2012-02-20 08:34:25+00:00
State: open

bernhard...@gmail.com, 2011-09-11T09:48:45.000Z

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.