I have a question regarding implementation of two __contains__ methods in rdflib/graph.py (sorry for bad formatting if any):
def __contains__(self, triple):
"""Support for 'triple in graph' syntax"""
for triple in self.triples(triple):
return True
return False
def __contains__(self, triple_or_quad):
"""Support for 'triple/quad in graph' syntax"""
s,p,o,c = self._spoc(triple_or_quad)
for t in self.triples((s,p,o), context=c):
return True
return False
These seem odd to me in that they return True immediately inside the loop without any conditionals present. According to my (limited) understanding of Python, the loops shall end unconditionally here after first pass.
What is the motivation behind this? Can someone explain in more detail how this actually works?
Thanks,
Grzegorz