You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Values are wrapped in rdflib.term.* objects. I noticed in these docs, a reference to the internal function rdflib.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:
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:
The following extension of the above code gets the desired output:
There are two actionable changes that could be considered:
expanding the documentation to mention .toPython(). Currently, it's used in an example (lit2006.toPython()), but much less obvious than the internal method rdflib.term._castLexicalToPython.
adding a method/property to rdflib.plugins.sparql.processor.SPARQLResult to make accessing .toPython values easy. For example, something like SPARQLResult.python_bindings, which would be like bindings but using native Python types. I am guessing this is what most users want when they make a query.
ghost
locked and limited conversation to collaborators
Dec 26, 2021
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?
The text was updated successfully, but these errors were encountered: