Cast XML Datatypes in SPARQL query results to native Python types? #1599
Replies: 1 comment
-
@matentzn provided the answer to my question in RDFLib/sparqlwrapper#125 (comment): the
The following extension of the above code gets the desired output: {str(k): None if v is None else v.toPython() for k, v in result.items()} There are two actionable changes that could be considered:
|
Beta Was this translation helpful? Give feedback.
-
I've begun using
rdflib
to query OWL ontologies using SPARQL. Thanks for this Python tool!Currently, I am using the API like:
If we then look at
result
:Values are wrapped in
rdflib.term.*
objects. I noticed in these docs, a reference to the internal functionrdflib.term._castLexicalToPython
.What is the recommended way to cast XML Datatypes from a SPARQL query result to native Python types? In my case, something that would produce output like:
Is there a straightforward way to get SPARQL results with Python types this I am overlooking?
Beta Was this translation helpful? Give feedback.
All reactions