summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshreyasnagare <shreyasnagare@gmail.com>2021-06-30 03:27:26 -0400
committershreyasnagare <shreyasnagare@gmail.com>2021-06-30 03:27:26 -0400
commitd6aa01db18739aea43177cfcec41f8667aebdb3d (patch)
tree907b039c98f7f09e91b0f1178e60ed778edd7fcb
parente4d975af6ee4e38b6bb7473b5660c84f787b5d94 (diff)
downloadrdflib-d6aa01db18739aea43177cfcec41f8667aebdb3d.tar.gz
Update graph operator overloading for subclasses
-rw-r--r--rdflib/graph.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/rdflib/graph.py b/rdflib/graph.py
index f90b3acb..c354a770 100644
--- a/rdflib/graph.py
+++ b/rdflib/graph.py
@@ -558,7 +558,7 @@ class Graph(Node):
def __add__(self, other):
"""Set-theoretic union
BNode IDs are not changed."""
- retval = Graph()
+ retval = self.__class__()
for (prefix, uri) in set(list(self.namespaces()) + list(other.namespaces())):
retval.bind(prefix, uri)
for x in self:
@@ -570,7 +570,7 @@ class Graph(Node):
def __mul__(self, other):
"""Set-theoretic intersection.
BNode IDs are not changed."""
- retval = Graph()
+ retval = self.__class__()
for x in other:
if x in self:
retval.add(x)
@@ -579,7 +579,7 @@ class Graph(Node):
def __sub__(self, other):
"""Set-theoretic difference.
BNode IDs are not changed."""
- retval = Graph()
+ retval = self.__class__()
for x in self:
if x not in other:
retval.add(x)