RDFLib / rdflib

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information.
https://rdflib.readthedocs.org
BSD 3-Clause "New" or "Revised" License
2.18k stars 558 forks source link

Add an unbind method on Graph and Namespace Manager to unbind prefixes #2862

Open edmondchuc opened 3 months ago

edmondchuc commented 3 months ago

Unbinding prefixes works on a Graph object with the memory store by passing None as the value and setting replace=True. If this is not a side effect and is the intended behaviour of unbinding prefixes, we can create an unbind method with the following implementation on a Graph.

def unbind(self, prefix: str):
    self.namespace_manager.bind(prefix, None, replace=True)

Will need to check whether this is the intended behaviour and whether this works consistently across store implementations.

An example on how to unbind a prefix: https://github.com/RDFLib/rdflib/issues/2643#issuecomment-1852991555

edmondchuc commented 1 week ago

Related discussion: https://github.com/RDFLib/rdflib/issues/1932.

edmondchuc commented 1 week ago

Related PR: https://github.com/RDFLib/rdflib/pull/1985.