def __init__(self, qResult):

        if isinstance(qResult, bool):
            type_ = 'ASK'

        elif isinstance(qResult, Graph):
            type_ = 'CONSTRUCT'

        else:
            type_ = 'SELECT'

        Result.__init__(self, type_)

        if self.type == 'ASK':
            self.askAnswer = qResult

        elif self.type == 'SELECT':
            result, selectionF, allVars, orderBy, distinct, topUnion = qResult

            if topUnion == None:
                raise Exception("No top union! %s"%topUnion)

            if selectionF == []: # select *
                self.vars = allVars
            else:
                self.vars = selectionF

            # self.bindings = [ dict( [ (v, b.get(v)) for v in self.vars ] ) for b in topUnion ]

            if len(self.vars) == 1:
                self.bindings = [dict(zip(self.vars, [b])) for b in result]

            else:
                self.bindings = [dict(zip(self.vars, b)) for b in result]

            # remove rows where all bindings are None
            self.bindings = filter(
                    lambda x: x.values() != [None]*len(x), self.bindings)

        else:
            self.graph = qResult
Test index page api/knowledge/categories
dataset/ETHPy150Open RDFLib/rdfextras/rdfextras/sparql/query.py/SPARQLQueryResult.__init__--crossover with--dataset/ETHPy150Open treeio/treeio/treeio/knowledge/api/tests.py/KnowledgeViewsTest.test_get_categories_list