walidazizi / rdflib

Automatically exported from code.google.com/p/rdflib
Other
0 stars 0 forks source link

toPython() for URIRef and BNode #188

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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.

Original issue reported on code.google.com by bernhard...@gmail.com on 11 Sep 2011 at 9:48