RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information. This library contains parsers/serializers for almost all of the known RDF serializations, such as RDF/XML, Turtle, N-Triples, & JSON-LD, many of which are now supported in their updated form (e.g. Turtle 1.1). The library also contains both in-memory and persistent Graph back-ends for storing RDF information and numerous convenience functions for declaring graph namespaces, lodging SPARQL queries and so on. It is in continuous development with the most recent stable release, rdflib 6.1.1 having been released on 20 December 2021. It was originally created by Daniel Krech with the first release in November, 2002. A number of other Python projects use rdflib for RDF manipulation, including: OWL-RL - A simple implementation of the OWL2 RL Profile (reasoning engine) pySHACL - a Python SHACL validator pyLDAPI - an add-on module for the Python Flask web framework used to deliver Linked Data pyLODE - a Web Ontology Language documentation tool History and status Overview RDFLib and Python idioms RDFLib's use of various Python idioms mean it is fairly simple for programmers with only junior Python skills to manipulate RDF. On the other hand, the Python idioms are simple enough that someone familiar with RDF, but not Python, can probably work out how to use rdflib quite easily. The core class in RDFLib is Graph which is a Python dictionary used to store collections of RDF triples in memory. It redefines certain built-in Python object methods in order to exhibit simple graph behaviour, such as simple graph merging via addition (i.e. g3 = g1 + g2). RDFLib graphs emulate container types and are best thought of as a set of 3-item triples: set([ (subject,predicate,object), (subject1,predicate1,object1), ... (subjectN,predicateN,objectN) ]) RDFLib graphs are not sorted containers; they have ordinary Python set operations, e.g. add() methods that search triples and return them in arbitrary order. RDF graph terms The following RDFLib classes (listed below) model RDF terms in a graph and inherit from a common Identifier class, which extends Python unicode. Instances of these are nodes in an RDF graph. URIRef BNode Literal Variable Namespace utilities RDFLib provides mechanisms for managing namespaces. In particular, there is a Namespace class which takes (as its only argument) the Base URI of the namespace. Fully qualified URIs in the namespace can be constructed by attribute / dictionary access on Namespace instances: >>>